[SOLVED]Toil and trouble help python

# Ogre Witches have some unpleasant surprises ready for you.

# Define a chooseTarget function which takes a friend argument
# Returns a target to attack, depending on the type of friend.
# Soldiers should attack the witches, archers should attack nearest enemy.
def chooseTarget(friend):
    enemies = friend.findEnemies()
    enemy = friend.findNearest(enemies)
    witches = self.findByType("witch", enemies)
    witch = friend.findNearest(witches)
    if friend and friend.type is "soldier" and enemy and witch and witch.health > 0:
            friend.command(friend, "attack", witch)
    if friend and friend.type is "archer" and enemy:
        self.command(friend, "attack", enemy)
    friends = self.findFriends()
    for friend in friends:
        # Use your chooseTarget function to decide what to attack.


Help please.


Never mind :disappointed_relieved::disappointed_relieved:


The biggest mistakes are the smallest.



yay I finally did it!!


you asked your friend to command him/herself.