I need help in Blind Distance!

Tell the wizard the distance to the coming ogres.

This function finds the nearest enemy and returns the distance to it.

If there is no enemy, the function returns 0.

def nearestEnemyDistance():
enemy = hero.findNearestEnemy()
result = 0
if enemy:
result = hero.distanceTo(enemy)
return result

while True:
# Call nearestEnemyDistance() and
# save the result in the variable enemyDistance.
enemyDistance = nearestEnemyDistance()
# If the enemyDistance is greater than 0:
if enemyDistance > 0:
# Say the value of enemyDistance variable.
hero.say(“enemyDistance”)

This is my code, any issues? so far I do not get any errors but my hero still dies, what armor/HP points do I need for this level? or Is it another issue?

Hi @xCodeSweat, welcome to the CodeCombat Discourse :tada:!
This issue is here:

You should only use “” in a hero.say() function if you want to say a message like: hero.say(“Hello Tharin”), or hero.say(“The password is abcdefg”). If you want to say the value, for example: 10, which is contained within the enemyDistance variable, you don’t use quotation marks, because that will just say: “enemyDistance”, which has no meaning. You want the number inside, not the variable name, so you have to remove “”.
I hope this helps,
Danny

1 Like

Hi @xCodeSweat, welcome to the CodeCombat Discourse :tada:!, Please format your code properly in the future, by using. This button: </>