# Please help me find the error in the Decoy Drill

**URL:** <https://discourse.codecombat.com/t/please-help-me-find-the-error-in-the-decoy-drill/13779>\
**Category:** Bugs\
**Created:** [February 5, 2018, 2:13am UTC](https://discourse.codecombat.com/t/please-help-me-find-the-error-in-the-decoy-drill/13779 "2018-02-05T02:13:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dead\_Com](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@Dead\_Com](https://discourse.codecombat.com/u/Dead_Com)\
**Post date:** [February 5, 2018, 2:13am UTC](https://discourse.codecombat.com/t/please-help-me-find-the-error-in-the-decoy-drill/13779/1 "2018-02-05T02:13:02Z")

</div>

````python
# Build 4 decoys, then report the total to Naria.
decoysBuilt = 0
gold = 0
while True:
    coin = hero.findNearestItem()
    
    if coin:
        # Collect the coin!
        gold += coin.value
        hero.moveXY(coin.pos.x, coin.pos.y)
        pass
    # Each decoy costs 25 gold.
    # If hero.gold is greater than or equal to 25:
    if hero.coin >= 25:
        # buildXY a "decoy"
        hero.buildXY("decoy", hero.pos.x - 5, hero.pos.y)
        # Add 1 to the decoysBuilt count.
        decoysBuilt += 1
    if decoysBuilt == 4:
        # Break out of the loop when you have built 4.
        break
        pass
    
hero.say("Done building decoys!")
hero.moveXY(14, 36)
# Say how many decoys you built.
hero.say(decoysBuilt)```
````

---

<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 5, 2018, 2:50am UTC](https://discourse.codecombat.com/t/please-help-me-find-the-error-in-the-decoy-drill/13779/2 "2018-02-05T02:50:27Z")

</div>

> [@Dead\_Com](#):
>
> Mod please fix it

Fix what? Your code, or the way you’ve posted it? Please include all of your code inside the triple back tick marks…

![PostCode](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/c/c959cbef5cb35fded8a40eb7ee3dc560f0064f68.JPG)

You got most of it in there, but not all of it. Because it’s not all formatted properly I can’t tell for sure, but it looks like a structure problem. Also, are you receiving an error? What happens when you run your code? Some information to work with would help us help you. Thank you.

---

<div class="post-metadata">

**Author:** ![Dead\_Com](https://avatars.discourse-cdn.com/v4/letter/d/a88e57/32.png) [@Dead\_Com](https://discourse.codecombat.com/u/Dead_Com)\
**Post date:** [February 5, 2018, 7:03pm UTC](https://discourse.codecombat.com/t/please-help-me-find-the-error-in-the-decoy-drill/13779/3 "2018-02-05T19:03:09Z")

</div>

I have resolved this problem. thank you

---

<div class="post-metadata">

**Author:** ![kyay10](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/kyay10/32/7337_2.png) [@kyay10](https://discourse.codecombat.com/u/kyay10)\
**Post date:** [February 5, 2018, 9:24pm UTC](https://discourse.codecombat.com/t/please-help-me-find-the-error-in-the-decoy-drill/13779/4 "2018-02-05T21:24:14Z")

</div>

instead of defining your own gold variable use hero.gold
