# Can I have help on blind distance

this is my code```

# 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:
hero.say(â€ś10â€ť)
# Say the value of enemyDistance variable.

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

It is important that we understand how your code is indented in Python to capture any mistakes related to that. Please read through the linked topic to learn how to do that.

I believe the issue is following the one line checking the distance. You are missing this part of code to make sure the distance is greater than 0.
`# If the enemyDistance is greater than 0:`

Also, make sure you say the variable, and not 10 like you currently have coded.

2 Likes

@brooksy125! Havenâ€™t seen you on for a long time!

1 Like

Welcome back, we havenâ€™t seen you in a while.

def nearestEnemyDistance():
enemy = hero.findNearestEnemy()
result = 10
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:
def nearestEnemyDistance():
enemy = hero.findNearestEnemy()
result = 10
if enemy:
result = hero.distanceTo(enemy)
return result

Donâ€™t share any solutions here. The person wouldnâ€™t learn nothing if you gave them working code.

You have to check if enemyDistance is greater than 0. If it is, say enemyDistance.

``````if enemyDistance > 0:
hero.say(enemyDistance)
``````

Thatâ€™s nothing related to the topic, please refrain from posting stuff that is not related to the topic
Lydia