August 2021
Beginner to intermediate
118 pages
1h 29m
English
| Puzzle 1 | Ready Player One |
| | class Player: |
| | # Number of players in the Game |
| | count = 0 |
| | |
| | def __init__(self, name): |
| | self.name = name |
| | self.count += 1 |
| | |
| | |
| | p1 = Player('Parzival') |
| | print(Player.count) |
Guess the Output | |
|---|---|
|
|
Try to guess what the output is before moving to the next page. |
This code will print: 0
When you write self.count, you’re doing an attribute lookup. The attribute you’re looking for, in this case, is count.
Read now
Unlock full access