The code's not working very well

I am doing the level “Decoy Drill”.
What’s wrong with my code?

# We are field testing a new battle unit: the decoy.
# Build 4 decoys, then report the total to Naria.
# Each decoy costs 25 gold. Use the Quartz Sense Stone
# to know when you have more than 25 gold with
# Keep a count of decoys you built as you go along.
# Break out of the loop when you have built 4.
decoysBuilt = 0
    item = self.findNearest(self.findItems())
        self.buildXY("decoy", self.pos.x, self.pos.y)
        self.moveXY(x, y)
    if decoysBuilt=4:
self.say("Done building decoys!")
# Go to Naria and say how many decoys you built.
self.moveXY(14, 36)
self.say("I built "+decoysBuilt+" decoys!")

The problem with claiming the “code is being an idiot” is that it usually back fires…

One, it would help if you told us what your code did or didn’t do…

But here is the answer anyway:

‘=’ is an assignment.

if decoysBuilt = 4:

sets decoysBuilt to 4

‘==’ is a conditional (asks about being equal)

if decoysBuilt == 4:

does things IF decoysBuilt “is-equal-to” 4

1 Like


(there is no :heart: button)

You were probably wondering what this meant. Well this popped up while I was typing “thanks”:
“Post must be at least 20 characters. Have you tried the :heart: button?”

:smiley: You have to wave your mouse over the post