# Long Range Division - Python

``````   # Destroy the mines!
# Use say to call out the range to the mines.
# Use division to calculate the range.
enemies = hero.findEnemies()
for enemy in enemies:
distanceToEnemy = hero.distanceTo(enemy)
distanceone = distanceToEnemy / 3
distancetwo = distanceToEnemy / 1.5

# Say first Range: distanceToEnemy divided by 3
hero.say("distanceone")
# Say second range: distanceToEnemy divided by 1.5
hero.say("distancetwo")

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

# Now, use a while-true loop to attack the enemies.
while True:
hero.attack(enemy)``````

Your distances are strings. `hero.say("when in quotations a string is displayed")` not a varriable. Take the quotations out and that should fix your problem. Something like this:

``````# Say first Range: distanceToEnemy divided by 3
hero.say(distanceone)
# Say second range: distanceToEnemy divided by 1.5
hero.say(distancetwo)
``````

I’m not sure about the particular level, but your last two lines will loop indefinitly attacking on one `enemy`. You may (if it is applicable) want to have it: find closest enemy, and attack it.

-Cheers

1 Like

that fixed it and your suggestion helped!

1 Like

# Use division to calculate the range.

enemies = hero.findEnemies()
for enemy in enemies:
distanceToEnemy = hero.distanceTo(enemy)
distanceone = distanceToEnemy / 3
distancetwo = distanceToEnemy / 1.5

# Say first Range: distanceToEnemy divided by 3

hero.say(distanceone)

# Say second range: distanceToEnemy divided by 1.5

hero.say(distancetwo)

# Say these things for motivation. Really. Trust us.

hero.say(“Woo hoo!”)
hero.say(“Here we go!”)
hero.say(“Charge!!”)

# Now, use a while-true loop to attack the enemies.

while True:
nearest = hero.findNearest(enemy)
hero.attack(enemy)

I only can attack 1 enemy , then it stop.
Can You guys help me with that ?
thanks