enemies = hero.findEnemies()
enemyIndex = 0
# Wrap this section in a while loop to iterate all enemies.
# While the enemyIndex is less than the length of enemies
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
# Remember to increment enemyIndex
enemyIndex += 1
I put the while true loop and did what it said but it says the loop never ended or is really slow
Hi @avery_witte, Welcome to Discourse
You have to put add 4 spaces in front of the lines below because they’re not in the while loop. Thus it either causes Infinte Loop or Making the code really slow.
enemies = hero.findEnemies()
enemyIndex = 0
# Wrap this section in a while loop to iterate all enemies.
# While the enemyIndex is less than the length of enemies
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy and enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
# Remember to increment enemyIndex
enemyIndex += 1