Pythonic python -- looping over lists

can someone help on this its saying X underneath hero but not showing anything wrong in the text (if this is in the wrong place please tell me (new to this)):stuck_out_tongue:

loop:
    # Collect gold.
    coin = self.findItems()
    gold = self.findNearest( golds )
    self.moveXY( gold.pos.x , gold.pos.y)
    # If you have enough gold, summon a soldier.
    if self.gold > self.costOf("soldier"):
        self.summon("soldier")
    # Use a for-loop to command each soldier.
    # For loops have two parts: "for X in Y"
    # Y is the array to loop over.
    # The loop will run once for each item in Y, with X set to the current item.
    for friend in self.findFriends():
        if friend.type == "soldier":
            enemy = friend.findNearestEnemy()
            # If there's an enemy, command her to attack.
            if enemy:
                self.command( friend, "attack", enemy )
            # Otherwise, move her to the right side of the map.
            else:
                pos = {'x':82, 'y':33}
                self.command( friend, "move", pos )

(formatting not working)
thanks