while True:
enemies = hero.findEnemies()
enemyIndex = 0
while True:
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type != "sand-yak":
while enemy.health > 0:
hero.attack(enemy)
enemyIndex = enemyIndex + 1
pass
# Between waves, move back to the center.
hero.moveXY(39, 32)
```I need help. My hero stops attacking after a few ogres. What is wrong with my code?
You don’t need a second while True: loop, you only need one of them, and a while enemyIndex loop
I think it works apart from that.
You are using too many while loop, this is why you dont see your error. There is 4 while loops in your code. The problem is with a variable.