while True: # Collect gold. item = hero.findNearestItem() hero.moveXY(item.pos.x, item.pos.y) # If you have enough gold, summon a soldier. if hero.gold > hero.costOf("soldier"): hero.summon("soldier") soldiers = hero.findFriends() soldierIndex = 0 # Add a while loop to command all the soldiers. soldier = soldiers[soldierIndex] while soldierIndex < len(soldiers): hero.command(soldiers[soldierIndex], "attack", enemy) soldierIndex +=1 # Use a for-loop to command each soldier. # For loops have two parts: "for X in Y" # Y is the array to loop over. # The loop will run once for each item in Y, with X set to the current item. for friend in hero.findFriends(): if friend.type == "soldier": enemy = friend.findNearestEnemy() # If there's an enemy, command her to attack. # Otherwise, move her to the right side of the map.