[Solved]I need help passing this level:Decoy drill

decoysBuilt = 0
while True:
coin = hero.findNearestItem()

if coin:
    # Collect the coin!
    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.gold <= 25:
    # buildXY a "decoy"
    hero.buildXY("decoy", x, 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(“4”)

At the first sight - I’m not sure that you really want to type

# If hero.gold is greater than or equal to 25:
if hero.gold <= 25:
    # buildXY a "decoy"
    hero.buildXY("decoy", x, y)
    # Add 1 to the decoysBuilt count.
    decoysBuilt += 1

Comments are important as far as they are a part of level instructions.

so what do I need to put?

Right condition maybe?
like # If hero.gold is greater than or equal to 25: advises.
Now your condition is controversial to the comment line.

I don’t understand.
does that mean I put: if hero.gold <= 25;

Hi pug333,

“if hero.gold <= 25” translates as “if hero.gold is less than or equal to 25”. Is that what you mean?

Jenny

yes but I still don’t know how to say it.

thanks I think I figured it out!

1 Like

Nope.
Your expression if hero.gold <= 25: literally means that hero.gold is less or equal 25.|

And hero.say(“Done building decoys!”) should be changed somehow. You don’t need to say “Done building decoys!” or put hero.say(“4”). decoysBuilt is variable that stores the quantity. Put it to the command hero.say

Personally me prefer wright this decoy cases as
if self.gold > 24