Blind disance help

this is my code so far:

# 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)

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

1 Like

Replace that with

if enemyDistance:
        
        # Say the value of enemyDistance variable.
        hero.say(enemyDistance)
1 Like

You have to check if the enemyDistance is greater than zero. Then you need to say enemyDistance with hero.say(enemyDistance).

1 Like

No you don’t.
20 char

1 Like

Read what the comments say.

1 Like

Oh yea, but for me I didn’t check.

1 Like

@codeneedhelp, after this part (outside of the if statement),you need to return result.

1 Like

You’re supposed to put

1 Like