Not quite. Because you’re function uses a single target soldier, you’ll need to also use a for loop somewhere to loop through each of your soldiers.
for friend in friends:
commandSoldier(fr...
This is an array, so you can’t use command with it - you can’t command a whole array in one statement (although that could be a cool feature if you just wanted all your troops to do the same thing…)
Danny
What @Deadpool198 is saying is that when you define soldier as a parameter in your function, you do not need to define it again. In this case, it would be likely that you are using more then one type of friend; it would definitely save time like this, so well done on that. If so, then you shouldn’t define soldier and leave the function as it was at the start of this topic.
Next you need to define a for-loop that iterates through your friends. I’ll leave that to you to think about but in this case
for each friend in your friends:
if your friend is a ...:
command...(friend)
you would carry on with the required friends.
Elijah
def commandSoldier(soldier):
#find friends
for friend in friends:
#if the friend type is soldier
#find the enemy nearest to the friend or find the enemy nearest to your hero
#if there is an enemy
#command your soldier to attack the enemy