OK, so the functions commandSoldier and commandArcher are like machines - they have an input, and then the machine does something with that input.
Starting at the bottom of your code:
if friend.type == "soldier":
# This friend will be assigned to the variable soldier in commandSoldier
elif friend.type == "archer":
# Be sure to command your archers.
then the commandSoldier(friend) has an input; you need to make the commandArcher() have an input as well.
So then functions with an input. Say you have a piece of code:
it’s like a machine that takes whatever word is put into the gloop position and crunches the rest of the code assuming that gloop has been replaced with the new word. So you can use this code to attack lots of different things - makeAttack(enemy) and if there’s an enemy the hero will attack it; makeAttack(ogre) and the hero will attack the ogre; makeAttack(friend) and the hero will attack the friend…).
So looking at your code:
# Soldiers should attack enemies.
friend = hero.findFriends()
if friend and friend.type == "soldier":
enemy = friend.findNearestEnemy()
hero.command(friend, "attack", enemy)
somewhere in this you need to have the input word (soldier), so that when we run the function as commandSoldier(friend), then the word friend will replace all the soldier words.
Try that for starters, post again if you’re still stuck.