Sarven Sentry Python help


#1
flagGreen = self.findFlag("green")
flagBlack = self.findFlag("black")
flagViolet = self.findFlag("violet")
if flagGreen: 
    self.moveXY(flagGreen.pos.x, flagBlack.pos.y)
    self.pickUpFlag(flagGreen)
    self.buildXY("fence", self.pos.x, self.pos.y)  
 elif flagBlack:
    self.moveXY(flagBlack.pos.x, flagBlack.pos.y)
    self.pickUpFlag(flagBlack)
    self.buildXY("fire-trap", self.pos.x, self.pos.y)      
 elif flagViolet:
    self.pickUpFlag(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.


#2

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


#3

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.