Long-Range Division - Python

Hello! I have been trying, I don’t know whats wrong with my code. It is only attacking 1 ogre. Please help, thank you!# Destroy the mines!

# Destroy the mines!
# Use `say` to call out the range to the mines.
# Use division to calculate the range.

enemy = hero.findNearestEnemy()
distanceToEnemy = hero.distanceTo(enemy)
# Say first Range: distanceToEnemy divided by 3
hero.say(distanceToEnemy / 3)
# Say second range: distanceToEnemy divided by 1.5
hero.say(distanceToEnemy / 1.5)

# Say these things for motivation. Really. Trust us.
hero.say("Woo hoo!")
hero.say("Here we go!")

# Now, use a while-true loop to attack the enemies.
while True:
    if enemy:

That’s because you are only defining one enemy. You also need to find enemy inside the while loop.

Thank you so much! It worked!

1 Like