Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

How to pass Blind Distance


I don’t know how to pass this level. Can anyone help?
Here is my code :

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.
distance = nearestEnemyDistance()
# If the enemyDistance is greater than 0:
if distance > 0 :
# Say the value of enemyDistance variable.

I think this is complicated :slight_smile:


You have defined the variable distance. Then when you call the variable with the hero.say method, you call it as a string. Once defined, a variable is not a string.


I don’t know what is a string XD
Can you explain?


String - a type of programming data that represents text.

Variable - a symbol that represents data.

In your case, you have defined the variable distance as the function, nearestEnemyDistance().

distance = nearestEnemyDistance()

A variable is not just a string of text, it is a value of data. When you use the method, hero.say(), you call the variable as a string, which, to the program, is just a bunch of letters with no meaning and no value. It is a string because it is in quotes. No quotes - it’s a variable. With quotes - it’s a string.


Thank you for sending me this. I worked on it, but the thing is, the blind magician just gets tired out. What should I do?


I just figured it out!