# Cursed Valley - Python

**URL:** <https://discourse.codecombat.com/t/cursed-valley-python/13230>\
**Category:** Uncategorized\
**Created:** [December 12, 2017, 4:37pm UTC](https://discourse.codecombat.com/t/cursed-valley-python/13230 "2017-12-12T16:37:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Adit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/adit/32/7048_2.png) [@Adit](https://discourse.codecombat.com/u/Adit)\
**Post date:** [December 12, 2017, 4:37pm UTC](https://discourse.codecombat.com/t/cursed-valley-python/13230/1 "2017-12-12T16:37:18Z")

</div>

hey guys… need help with my code- dunno wats wrong  
while True:  
enemy = hero.findNearestEnemy()  
# Attack if enemy exists AND enemy.team is “ogres”  
# AND enemy.type is "skeleton"  
if enemy and enemy.team == “ogres” and enemy.type == “skeleton”:  
hero.attack(enemy)

```
item = hero.findNearestItem()
# Collect if item exists AND item.type is "potion"
# AND hero.health is less than hero.maxHealth / 4
if item and item.type =="potion" and hero.health =="hero.maxHealth" / 4:
    hero.moveXY(item.posx, item.pos.y)

```

my hero stops moving after killing the first skeleton

---

<div class="post-metadata">

**Author:** ![John\_F\_Morrison\_Jr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/john_f_morrison_jr/32/7149_2.png) [@John\_F\_Morrison\_Jr](https://discourse.codecombat.com/u/John_F_Morrison_Jr)\
**Post date:** [December 12, 2017, 5:01pm UTC](https://discourse.codecombat.com/t/cursed-valley-python/13230/2 "2017-12-12T17:01:29Z")

</div>

```python
if item and item.type =="potion" and hero.health =="hero.maxHealth" / 4:
    hero.moveXY(item.posx, item.pos.y)

```

is your problem  
I would try removing quotes from hero.maxHealth  
also should be item.pos.x

---

<div class="post-metadata">

**Author:** ![Adit](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/adit/32/7048_2.png) [@Adit](https://discourse.codecombat.com/u/Adit)\
**Post date:** [December 13, 2017, 10:05am UTC](https://discourse.codecombat.com/t/cursed-valley-python/13230/3 "2017-12-13T10:05:20Z")

</div>

im sorry…i was still not able to finish it

here is my code

item = hero.findNearestItem()  
# Collect if item exists AND item.type is “potion”  
# AND hero.health is less than hero.maxHealth / 4  
if item and item.type ==“potion” and hero.health == hero.maxHealth / 4:  
hero.moveXY(item.pos.x, item.pos.y)
