Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Sarven Sentry Python help

flagGreen = self.findFlag("green")
flagBlack = self.findFlag("black")
flagViolet = self.findFlag("violet")
if flagGreen: 
    self.moveXY(flagGreen.pos.x, flagBlack.pos.y)
    self.buildXY("fence", self.pos.x, self.pos.y)  
 elif flagBlack:
    self.moveXY(flagBlack.pos.x, flagBlack.pos.y)
    self.buildXY("fire-trap", self.pos.x, self.pos.y)      
 elif flagViolet:

I can’t figure out why it is going wrong and not working. Could someone please help with this I can’t find the error.


please surround your code with three of these things ` so it’s easier to read (three above and three below the code)

if flagGreen: 
    self.moveXY(flagGreen.pos.x, flagBlack.pos.y)

something is not quite right here


Yes, as zimmah has said, surround your code with backticks, which is the key directly above the Tab key. See the FAQ for more information. I have formatted your code for you this time, but please do so yourself in the future.

Two things:
You have not surrounded your code in a loop.
Also, your elif statements are indented by one space. This should not be.