[Solved] Dust infinite loop

I’m doing dust when I submit when he retreats he freezes and it says that there is a infinite loop

# Use a while to loop until you have counted 10 attacks.

attacks = 0
while attacks < 10:
    # Attack the nearest enemy!
    enemy = hero.findNearestEnemy()
    # Incrementing means to increase by 1.
    # Increment the `attacks` variable.
    attacks += 1

# When you're done, retreat to the ambush point.
hero.say("I should retreat!") 
hero.moveXY(79, 33)

Have you checked if there is an enemy?

1 Like

he still attacks the enemy’s

Check if there is an enemy, and please post your updated code.

got it to work (20) charecters

1 Like

Congrats!! :partying_face: :partying_face:

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.