# \[SOLVED\] Blind Distance

**URL:** <https://discourse.codecombat.com/t/solved-blind-distance/27385>\
**Category:** Level Help\
**Created:** [February 10, 2021, 8:53pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385 "2021-02-10T20:53:10Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Giovanni\_Busacca](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/giovanni_busacca/32/20806_2.png) [@Giovanni\_Busacca](https://discourse.codecombat.com/u/Giovanni_Busacca)\
**Post date:** [February 10, 2021, 8:53pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/1 "2021-02-10T20:53:10Z")

</div>

Hi, I have been on this level for quite some time now approx. 2.5 hours and I can’t figure out what is wrong with my code can someone help?  
Here is my code:

```python
# 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 hero.distanceTo > 0 : 
        # Say the value of enemyDistance variable.
        hero.say("nearestEnemyDistance()")

```

---

<div class="post-metadata">

**Author:** ![Chaboi\_3000](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/chaboi_3000/32/48486_2.png) [@Chaboi\_3000](https://discourse.codecombat.com/u/Chaboi_3000)\
**Post date:** [February 10, 2021, 8:56pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/2 "2021-02-10T20:56:50Z")

</div>

Remove the quotes in `hero.say("nearestEnemyDistance()")`. Quotes will make your hero say exactly what’s inside the quotes, but since you want to say the **return value** instead of just `nearestEnemyDistance()`, you’d have to change that to `hero.say(nearestEnemyDistance())`

---

<div class="post-metadata">

**Author:** ![Giovanni\_Busacca](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/giovanni_busacca/32/20806_2.png) [@Giovanni\_Busacca](https://discourse.codecombat.com/u/Giovanni_Busacca)\
**Post date:** [February 10, 2021, 9:01pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/3 "2021-02-10T21:01:44Z")

</div>

> [@Chaboi\_3000](#):
>
> hero.say(nearestEnemyDistance())

…  
so it is line 19?

---

<div class="post-metadata">

**Author:** ![Giovanni\_Busacca](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/giovanni_busacca/32/20806_2.png) [@Giovanni\_Busacca](https://discourse.codecombat.com/u/Giovanni_Busacca)\
**Post date:** [February 10, 2021, 9:03pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/4 "2021-02-10T21:03:12Z")

</div>

The code gets stuck on the return command why is this?

---

<div class="post-metadata">

**Author:** ![abc](https://avatars.discourse-cdn.com/v4/letter/a/2bfe46/32.png) [@abc](https://discourse.codecombat.com/u/abc)\
**Post date:** [February 10, 2021, 9:06pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/5 "2021-02-10T21:06:45Z")

</div>

> [@Giovanni\_Busacca](#):
>
> ```python
> if hero.distanceTo > 0 : 
> # Say the value of enemyDistance variable.
> hero.say("nearestEnemyDistance()")
> 
> ```

Change the if statement to:

```python
if enemyDistance > 0:

```

Then inside of the if statement, say enemyDistance.

---

<div class="post-metadata">

**Author:** ![Giovanni\_Busacca](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/giovanni_busacca/32/20806_2.png) [@Giovanni\_Busacca](https://discourse.codecombat.com/u/Giovanni_Busacca)\
**Post date:** [February 10, 2021, 9:08pm UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/6 "2021-02-10T21:08:27Z")

</div>

Thank you this helped a lot.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [February 11, 2021, 9:09am UTC](https://discourse.codecombat.com/t/solved-blind-distance/27385/7 "2021-02-11T09:09:23Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
