[SOLVED] Lurkers need help

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 :tada: :partying_face:
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.

I did that but the charecter stays still

Can you show me your revised code?

Umm you didn’t change anything.

I did I put the spaces but my cursor was not on it so it did not show but it is there

Deleted

You have to delete “return” in the beginning of your program.

alright i did that and my charecter is staying still

Put 4 spaces in front of the enemyIndex, it should work now.

Try to write

if enemy and enemy.type == "shaman"
1 Like

Good suggestion but it’s the same thing.

he just stays still even with the spaces in front of enemy index

I didn’t say that it is the same thing.

1 Like

Can I see the code not the screenschot.

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 

You didn’t put 4 spaces in front of this, the enemyIndex has to inside the while loop.