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


#1

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
loop:
coin = self.findNearest(self.findItems())

if coin:
    # Loot the coin!
    position = coin.pos
    x = position.x
    y = position.y
    self.moveXY(x, y)
    totalGold = self.gold + 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 self.gold


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

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

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

any help would be appreciated thanks


#2

Never mind I fixed it sigh