# Blind disance help

**URL:** <https://discourse.codecombat.com/t/blind-disance-help/27421>\
**Category:** Level Help\
**Created:** [February 13, 2021, 12:27am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421 "2021-02-13T00:27:16Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![codeneedhelp](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/codeneedhelp/32/20355_2.png) [@codeneedhelp](https://discourse.codecombat.com/u/codeneedhelp)\
**Post date:** [February 13, 2021, 12:27am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/1 "2021-02-13T00:27:17Z")

</div>

this is my code so far:

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

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.
        

```

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [February 13, 2021, 12:44am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/2 "2021-02-13T00:44:43Z")

</div>

> [@codeneedhelp](#):
>
> ```python
> if enemyDistance > 5:
> hero.say("10")
> 
> ```

Replace that with

```python
if enemyDistance:
        
        # Say the value of enemyDistance variable.
        hero.say(enemyDistance)

```

---

<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 13, 2021, 12:47am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/3 "2021-02-13T00:47:35Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [February 13, 2021, 12:49am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/4 "2021-02-13T00:49:02Z")

</div>

No you don’t.  
20 char

---

<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 13, 2021, 12:49am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/5 "2021-02-13T00:49:37Z")

</div>

Read what the comments say.

---

<div class="post-metadata">

**Author:** ![Eric\_Tang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/eric_tang/32/15310_2.png) [@Eric\_Tang](https://discourse.codecombat.com/u/Eric_Tang)\
**Post date:** [February 13, 2021, 12:50am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/6 "2021-02-13T00:50:46Z")

</div>

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

---

<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 13, 2021, 12:52am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/7 "2021-02-13T00:52:28Z")

</div>

> [@codeneedhelp](#):
>
> ```python
> if enemy:
> result = hero.distanceTo(enemy)
> 
> ```

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

---

<div class="post-metadata">

**Author:** ![Monsty](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/monsty/32/20923_2.png) [@Monsty](https://discourse.codecombat.com/u/Monsty)\
**Post date:** [February 13, 2021, 3:36am UTC](https://discourse.codecombat.com/t/blind-disance-help/27421/8 "2021-02-13T03:36:42Z")

</div>

> [@codeneedhelp](#):
>
> ```python
> if enemyDistance > 5:
> hero.say("10")
> 
> ```

You’re supposed to put

> [@codeneedhelp](#):
>
> ```python
> if enemyDistance > 0:
> hero.say(enemyDistance)
> 
> ```
