Help with Drop the Flag? ;~;

I’ve been stuck on this level for a while now, any help with it? ^^;

loop:
    flag = self.findFlag()
    if flag:
        fx = self.findFlag()
        fy = self.findFlag()
        
        self.buildXY("fire-trap", fx, fy)
        self.pickUpFlag(flag)
    else:
        item = self.findNearestItem()
        if item:
            pos = item.pos
            itemX = pos.x
            itemY = pos.y
            self.moveXY(itemX, itemY)

When you are trying to set fx and fy you will need to look at the flag.pos.x and flag.pos.y Does that help?

Exactly as matt said. your flag code is incorrect

flag = self.findFlag()
if flag:
    self.buildXY("fire-trap", flag.pos.x, flag.pos.y)
    self.pickUpFlag(flag)
else:
    item = self.findNearestItem()
    if item:
        self.moveXY(item.pos.x, item.pos.y)

Thank you so much ^-^