Aug-23-2022, 08:54 PM
How is it not working? Does your program crash with an error message? If so, please post the error message. The code you've posted does not run. Your are missing Player.save() and Player.load() methods. When I remove the game code that saves and loads player 1, the program appears to work. This command:
This comment:
This comment:
print(player1.has_pokemon_left())prints
Output:True
next_pokemon() doesn't look right to me. I would expect that to return the next pokemon, not the first pokemon. Maybe writing an iterator that lets you loop through your pokemon is a future lesson.This comment:
Quote:As a reminder, we can use the following code to overwrite the default str function of a class.Is telling you wo write a __str__() method for your Player class so you get something better than:
Output:<__main__.Player object at 0x0000022204EC1460>
when you print(player).This comment:
Quote:However, whenever you have if A return True else return False , you should always just return A. So our code should be rewritten like this:Is telling you to rewrite this:
def is_alive(self): if self.health > 0: return True else: return FalseI'm telling you that there is no need to have this method defined in each of your Pokemon subclasses. It should be in the Pokemon class, and Pikachu and others should inherit the method. Maybe that is also a later lesson.