MY CODE
while True:
greenFlag = hero.findFlag("green")
if greenFlag:
hero.pickUpFlag(greenFlag)
else:
if enemy:
enemy = hero.findNearestEnemy()
hero.attack(enemy)
else:
pass
MY HERO ONLY COLECT THE FLAG IT DOSENT FIGHT
I think that you should delete this else.
Andrei
You need to define ‘enemy’ before using it in an if statement.
1 Like
The statement ‘if enemy’ will forever be False, because you don’t define ‘enemy’ until the line after…reverse these two lines, instead.
1 Like
Then congratulations for completing the level!
Andrei
system
Closed
9
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.