Help on Peek-A-Boom


#1

Hey dudes, I was having a little trouble on Pee A Boom. It said I needed to pair the else statement with the if statement, I did that, and it is still saying the same thing. Help would be appreciated anyone can help but help would especially be appreciated from @nick. Thanks!

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.buildXY("fire-trap", 41, 24)
        hero.moveXY(15, 16)
        pass
while True:
        
    else:
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.buildXY("fence", 41, 24)
            hero.moveXY(15, 16)

#2

Never heard of a level called “Pee” a Boom :laughing:. Jokes aside, you do not need 2 While True loops in this level. Get rid of the second while true loop. It separates the if and else, so the system bugs out, trying to look for the if of the else.


#3

I did that and now it completes the commands the first time but will not execute them continually.

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.buildXY("fire-trap", 41, 24)
        hero.moveXY(15, 16)
        pass


    else:
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.buildXY("fence", 41, 24)
            hero.moveXY(15, 16)

#4

No. Instead of building a fence, you just move back to wooden X. No need to find nearest enemy again. That was the purpose of the first if statement.


#5

Now it says the else must be paired with the ``if```` again

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        # <%= build_fire-trap %>
        hero.buildXY("fire-trap", 36, 30)
        hero.moveXY(19, 19)
        pass

    else:
        hero.buildXY("fire-trap," 36, 30)
        hero.moveXY(19, 19)

#6

I don’t think you need that second hero.buildXY("fire-trap", 36, 30)


#7

Try three things. Eliminate the one line of space between the pass command and the else statement. Also, get rid of the buildXY in the else statement. Now, change the build fire trap location in the if statement to build on the red X.


#9

He already has that in his code, so there’s no issue there.


#10

look at this bug


#11

What is if else:?
You do not need to set up a separate while-true loop. Just include an else-statement in the first one.
No need to use a fence either :slight_smile:


#12

im stuck becasue like i tried all of these no did not work someone gets blown up!!!


#13

Please post your code and give any other additional information that would be helpful


#14

I did this and it works try it

(Solution removed)


#15

Please don’t post solutions. The purpose of this board is to help people learn so that they can figure out levels on their own. Simply providing solutions does not help and is counterproductive to this goal. The two main rules here on this board are no swearing and no posting solutions. Thanks and welcome to the board.