# Double Check - item.type?

**URL:** <https://discourse.codecombat.com/t/double-check-item-type/12025>\
**Category:** Adventurer\
**Created:** [July 24, 2017, 5:00pm UTC](https://discourse.codecombat.com/t/double-check-item-type/12025 "2017-07-24T17:00:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![XxToxicGamerxX](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xxtoxicgamerxx/32/6599_2.png) [@XxToxicGamerxX](https://discourse.codecombat.com/u/XxToxicGamerxX)\
**Post date:** [July 24, 2017, 5:00pm UTC](https://discourse.codecombat.com/t/double-check-item-type/12025/1 "2017-07-24T17:00:48Z")

</div>

Here is what I got

defeatedOgres = 0

while defeatedOgres \< 6:  
enemy = hero.findNearestEnemy()  
if enemy:  
hero.attack(enemy)  
defeatedOgres += 1  
else:  
hero.say(“Ogres!”)

hero.moveXY(49, 36)

while hero.gold \< 30:

```
coin = hero.findNearestItem()
if item.type == "coin":
    hero.moveXY(coin.pos.x, coin.pos.y)

```

hero.moveXY(76, 32)

It says that item.type is wrong and says that item is not defined?

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [July 24, 2017, 7:20pm UTC](https://discourse.codecombat.com/t/double-check-item-type/12025/2 "2017-07-24T19:20:36Z")

</div>

From what I see, you have defined the nearest item your hero finds as `coin` and not `item`.

---

<div class="post-metadata">

**Author:** ![XxToxicGamerxX](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/xxtoxicgamerxx/32/6599_2.png) [@XxToxicGamerxX](https://discourse.codecombat.com/u/XxToxicGamerxX)\
**Post date:** [July 25, 2017, 5:04pm UTC](https://discourse.codecombat.com/t/double-check-item-type/12025/3 "2017-07-25T17:04:41Z")

</div>

here’s now what i got( and a sucess 😉 )

defeatedOgres = 0

while defeatedOgres \< 6:  
enemy = hero.findNearestEnemy()  
if enemy:  
hero.attack(enemy)  
defeatedOgres += 1  
else:  
hero.say(“Ogres!”)

hero.moveXY(49, 36)  
coin = hero.findNearestItem()  
while hero.gold \< 30:  
Find and collect coins.  
coin = hero.findNearestItem()  
if “coin”:  
hero.moveXY(coin.pos.x, coin.pos.y)

hero.moveXY(76, 32)

---

<div class="post-metadata">

**Author:** ![Hellenar](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/hellenar/32/9100_2.png) [@Hellenar](https://discourse.codecombat.com/u/Hellenar)\
**Post date:** [July 26, 2017, 4:59am UTC](https://discourse.codecombat.com/t/double-check-item-type/12025/4 "2017-07-26T04:59:46Z")

</div>

Good job! 😄 But don’t post solutions as they let users just trying to pass copy the correct code without learning anything.
