Problem with pokemon master project

I spent almost too much time doing this, I tried to add more pokemon to the list, but all I am getting is this error message:

"
Traceback (most recent call last):
File “script.py”, line 116, in
trainer_main.attack_other_trainer(trainer_enemy)
File “script.py”, line 90, in attack_other_trainer
self.current_poke.attack(enemy)
File “script.py”, line 46, in attack
if (self.ptype == opponent.ptype) or (self.ptype == ‘fire’ and opponent.ptype == “poison”) or (self.ptype == ‘poison’ and opponent.ptype == “fire”) or (self.ptype == ‘ice’ and opponent.ptype == “poison”) or (self.ptype == ‘poison’ and opponent.ptype == “ice”) or (self.ptype == ‘water’ and opponent.ptype == “ice”) or (self.ptype == ‘ice’ and opponent.ptype == “water”) or (self.ptype == ‘poison’ and opponent.ptype == “water”) or (self.ptype == ‘water’ and opponent.ptype == “poison”):
AttributeError: ‘Trainer’ object has no attribute ‘ptype’
"

I am also getting this error if I try to print the trainer:

"
The trainer is called Chainsaw and currently has 5 potion(s). His current pokemon is Vulpix is at 5 and has 25 and has these pokemon:
Charmeleon is at 5 and has 25
Vulpix is at 5 and has 25
Traceback (most recent call last):
File “script.py”, line 116, in
print(trainer_main)
TypeError: str returned non-string (type NoneType)
"

It prints it, but gives an error message. I am not sure why.

This is being quite the challenge.

Looking through the code at the moment. I believe your print issue occurs as you have a repr atttribute without a return. I can see that throwing some errors if you ever tried to print it.
Will update if I find anything else.

Edit: Struggled with the formatting a touch. You might want to find a way of shortening some of those statements. I believe the issue is from the (self.ptype == opponent.ptype) style statements. opponent.ptype is not defined.

However you defined self.ptype you might want to make sure the “opponent” gets the same.

2 Likes