returns
Traceback (most recent call last):
File “script.py”, line 139, in
print(trainer_one)
File “script.py”, line 61, in repr
for pokemon in self.pokemon:
AttributeError: ‘Trainer’ object has no attribute ‘pokemon’
help please
returns
Traceback (most recent call last):
File “script.py”, line 139, in
print(trainer_one)
File “script.py”, line 61, in repr
for pokemon in self.pokemon:
AttributeError: ‘Trainer’ object has no attribute ‘pokemon’
help please
From your code:
class Trainer:
def __init__(self, pokemon_list, num_potions, name):
self.pokemons = pokemon_list
self.potions = num_potions
self.current_pokemon = 0
self.name = name
Read the error message carefully.
It says there is no attribute called pokemon
in the Trainer
class. I don’t see an attribute called pokemon
either. Do you?
so what should I do? I down think it should “pokemon” should be there, in the solution its exactly like that, and I’ve tried adding “pokemon” but no luck
You just have to use consistent spelling. The class attribute is named: pokemons
class Trainer:
def __init__(self, pokemon_list, num_potions, name):
self.pokemons = pokemon_list
# ^^^^^^^^
self.potions = num_potions
self.current_pokemon = 0
self.name = name
In your __repr__
method, you refer to the attribute as pokemon
:
Decide which spelling you want to use, and be consistent.
thanks it worked now, missed that one