Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Conditional loop breaks?


hey guys, this might seem a touch obvious but would really apreciate the help. ive managed to scroll through and kill all the archers on the level im on. the problem is i then want to break the loop and start again but with a different enemy type. my question is how i break the loop once there no archers left? here my code so far:

enemies = self.findEnemies()
enemyIndex = 0

while enemyIndex < len(enemies):    
    enemy = enemies[enemyIndex]
    if enemy.type == 'archer':
        while > 0:
            if self.isReady("cleave"):
    enemyIndex += 1

idealy i want to say something like :

if no enemy.type == ‘archer’:

but i cant get my head around it. please help x


Try this:

archer = self.findNearest(self.findByType("archer"))
if not archer: