I get an error saying “friend” is undefined while it actually does get defined one line above the statement. I can pass the level just fine (with the lure yeti bonus) but my ally won’t attack the enemy ogres, probably due to this error, and I really want to understand what’s wrong. I originally had ‘‘soldier’’ instead of ‘‘friend’’ but I keep looking at a previous level to get this right, and nothing works.
while True:
soldiers = hero.findFriends()
for i in range(len(points)):
point = points[i]
friend = soldiers[i]
enemy = friend.findNearestEnemy()
if enemy and enemy.type != "yeti":
hero.command(friend, "attack", enemy)
else:
hero.command(friend, "move", point)