# "Defeat the ogres scout"

**URL:** <https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068>\
**Category:** Solved\
**Created:** [February 28, 2018, 3:45am UTC](https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068 "2018-02-28T03:45:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Inukaze](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/inukaze/32/7492_2.png) [@Inukaze](https://discourse.codecombat.com/u/Inukaze)\
**Post date:** [February 28, 2018, 3:45am UTC](https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068/1 "2018-02-28T03:45:54Z")

</div>

Hi there in the level “[Saven Road](https://codecombat.com/play/level/sarven-road?)”

when i put the follow code :

```python
# Llegar al oasis. Cuidado con los nuevos enemigos: ogros exploradores!
# Subir y hacia la derecha añadiendo a la posición X e Y actual.
Enemigo = hero.findNearestEnemy()
while True:
    # Si hay un enemigo, ataca.
    if Enemigo:
	    hero.attack(Enemigo)
    # De lo contrario, sigue moviéndote hacia arriba y hacia la derecha. 
    else:
	    X = hero.pos.x + 1
	    Y = hero.pos.y + 1
	    hero.moveXY(X, Y)

```

i reach the Oasis, but my hero, never attack the ogres scout, and they reach with me the oasis xD

 ![ServenRoad](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/c/c0a4832e14491f491d7a7daf4de94b48e5565c63.png)

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [February 28, 2018, 11:56am UTC](https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068/2 "2018-02-28T11:56:53Z")

</div>

Try defining your variable as enemigo instead of Enemigo.

Intenta definir tu variable como enemigo en lugar de Enemigo.

---

<div class="post-metadata">

**Author:** ![Inukaze](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/inukaze/32/7492_2.png) [@Inukaze](https://discourse.codecombat.com/u/Inukaze)\
**Post date:** [February 28, 2018, 11:32pm UTC](https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068/3 "2018-02-28T23:32:18Z")

</div>

That don’t make any difference, because is just a variable name, besides, in the previous levels I have not had problems using practically the same parts of code

Eso no hace diferencia alguna, debido a que es solo el nombre de una variable. Ademas, en los niveles anteriores no he tenido problemas usando prácticamente las mismas partes de código!

Captura%20de%20pantalla%20-%20280218%20-%2019%3A32%3A58|690x479

---

<div class="post-metadata">

**Author:** ![MunkeyShynes](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/munkeyshynes/32/9277_2.png) [@MunkeyShynes](https://discourse.codecombat.com/u/MunkeyShynes)\
**Post date:** [February 28, 2018, 11:39pm UTC](https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068/4 "2018-02-28T23:39:23Z")

</div>

With your variable outside the while True loop, it is a global variable. Global variables are generally not a good idea and should be avoided. Move your variable definition inside the while True loop and before the if enemy conditional statement.

---

<div class="post-metadata">

**Author:** ![Inukaze](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/inukaze/32/7492_2.png) [@Inukaze](https://discourse.codecombat.com/u/Inukaze)\
**Post date:** [February 28, 2018, 11:56pm UTC](https://discourse.codecombat.com/t/defeat-the-ogres-scout/14068/5 "2018-02-28T23:56:37Z")

</div>

for me is some strange, because on all levels i play before, ever i put that goblal variables, i just in that level, make that.

well i put the variable, inside the “while True:” and now it’s working

```python
# https://codecombat.com/play/level/sarven-road?
# Llegar al oasis. Cuidado con los nuevos enemigos: ogros exploradores!
# Subir y hacia la derecha añadiendo a la posición X e Y actual.
while True:
    # Si hay un enemigo, ataca.
    enemigo = hero.findNearestEnemy()
    if enemigo:
	    hero.attack(enemigo)
    # De lo contrario, sigue moviéndote hacia arriba y hacia la derecha. 
    else:
	    X = hero.pos.x + 1
	    Y = hero.pos.y + 1
	    hero.moveXY(X, Y)

```

 ![Captura%20de%20pantalla%20-%20280218%20-%2019%3A32%3A58](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/f/f427167146282d645fe73a2481c1afd0cac89991.png)

and i think the bug its, with the first code i put, my hero never attack the ogres, but the level mark positive “Defeat the ogre scouts”
