Skip to content

Tag: python

Python .replace() function doesn’t seem to do anything

I’m trying to modify a table I scraped of Yahoo Finance containing dividends over the last 5 years. An example row of this table is: “1.50 Dividend”. As I want to do calculations with this table I needed only the number in the form of a float. So I used the .replace(“Dividend, “&…

Python AttributeError When Attribute is Set

I am creating a snake clone using pygame and I am running into a strange problem. I have a class called snake_tile that inherits from the pygame rectangle class with one additional attribute, the direction the tile is moving: I pass in a tuple as the direction when initializing the snake_tile object: Which wi…

$elemMatch to fetch specific values inside array

I have a collection named ‘attendance’ that has an array: I have been trying to query the values of the specific element in my array using $and and $elemMatch in: But it still prints the other section rather than one. I want to output to be: And I tried using the dot notation like: Still no luck. …