Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Toil and Trouble SOS

I don’t get toil and trouble please help:

# Ogre Witches have some unpleasant surprises ready for you.

# Define a chooseTarget function which takes a friend argument
# Returns the a target to attack, depending on the type of friend.
# Soldiers should attack the witches, archers should attack nearest enemy.


while True:
    friends = hero.findFriends()
    for friend in friends:
        # Use your chooseTarget function to decide what to attack.
        
        pass

Which world is this one in?

Hi @ww2_tanker.
You need to add a chooseTarget function to your code. (I know you already know this, I’ll explain some more)
So why don’t you start with one line:

def chooseTarget(friend):

As it says in the comments you need to have an argument, in this case it’s “friend”. Arguments are things which go in the brackets of functions.
You use the friend variable inside the function. Remember it’s a single friend, not an array of friends.

Why not define to variables: nearest and witch which you can return depending on whether the friend’s type is a “soldier” or an “archer”?
You’ll also need to complete the while True loop. But I’ll end my advice there, I don’t want to give to much away :wink:.
I hope this helps,
Danny

1 Like

After you try to make the level with the wonderful advice that @Deadpool198 gave you and you still need help, feel free to send us a fresh copy of your code.

Andrei