Attack enemies one by one

in the level Cloudrip Brawl i want to attack the enemies one by one so i made this code but i keep getting infinite loop

here is my code

self.toggleFlowers(False)
loop:
    soldiers = self.findFriends()
    enemies = self.findEnemies()
    index=0
    enemy = enemies[index]
    if self.costOf("soldier")<self.gold:
        self.summon("soldier")
    else:
        coin = self.findNearest(self.findItems())
        self.move(coin.pos)
    if enemy:
        while len(enemies) > index  :
            for soldier in soldiers:
                self.command(soldier, "attack", enemy)
            index =+1

The infinite loop is probably caused by the “index =+ 1”, it is supposed to be “index += 1”.

1 Like

i tried to change everything in the code but i never saw this :smiley: thanks for your help

1 Like

Glad to be of help. I’ve been there too.