Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Decoy Drill: Code does not finish in time and gets stuck on the last decoy


New to this and having students work through python. I am stuck on Decoy Drill where it just sits there on the last decoy and I run out of time.

Here is my code:

decoysBuilt = 0
totalGold = 0
coin = self.findNearest(self.findItems())

if coin:
    # Loot the coin!
    position = coin.pos
    x = position.x
    y = position.y
    self.moveXY(x, y)
    totalGold = + coin.value
    if totalGold >= 25:
        self.buildXY("decoy", self.pos.x + 1, self.pos.y)
        decoysBuilt = decoysBuilt + 1
# Each decoy costs 25 gold.
# Know when you have more than 25 gold with

    # Keep a count of decoys you built as you go along.

if decoysBuilt == 4:
    # Break out of the loop when you have built 4.

self.say(“Done building decoys!”)
self.moveXY(14, 36)
self.say(“4 decoys built!”)
self.moveXY(14, 36)

any help would be appreciated thanks


Never mind I fixed it sigh