Stuck in the same lvl for a week

This is my code for lvl 1 of cloudrip brawl, I collect the coins and summon my soldiers, but mosst of them just stand still and get killed. I would like all of them to attack the same enemie, and then go on to the next enemie, but I haven’t figure it out now. I understand the problem, but I just can’t find the solution, I have tried a lot of possible solutions with the while loop, but none of them seems to work.

loop:
    enemies = self.findEnemies()
    enemy = self.findNearest(enemies)
    coins = self.findItems()
    coin = self.findNearest(coins)
    friends = self.findFriends()
    friend = self.findNearest(friends)
    
    if coin:
        self.move(coin.pos)

    if self.gold > 20:
        self.summon("soldier")
        if enemy:
            self.command(friend, "attack", enemy)
    if enemy:
        self.command(friend, "attack", enemy)

Lannister, as a member of our community for two weeks, one would have thought that you would have read the FAQ and learned how to format your code properly, which you were supposed to do before posting. I will format your code for you, just this once, but you must learn how to do so in the future.

Use a for-loop to loop over all your friends (for friend in self.findFriends():). Then, find your nearest enemy. If there is one, command each friend to attack it.