Help with drop-the-flag

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

after character places 2nd mine in the middle they just walk into it and blow themselves up

You’re missing the point of this level. The objective is to place a fire trap where you place a flag, not place a fire trap on all three places.