[SOLVED] Preferential treatment

i tried to complete this level for the past 4 days , and i still cant fix it!
this is what my code looks like:

# First, loop through all enemies...
enemies = self.findEnemies()
enemyIndex = 0
# ... but only attack 'thrower' type enemies.
# And don't forget to use your special abilities!
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy.type == 'trower':
        while enemy.self.health >0:
            if self.isReady("cleave"):
                self.cleave(enemy)
            else:
                self.attack(enemy)
    enemyIndex += 1            
# Then loop through all the enemies again...
enemies = self.findEnemies()
enemyIndex = 0
# ... and take out everyone who's still standing.
while  enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    while enemy.health > 0:
        self.attack(enemy) 
    enemyIndex += 1    

i have tried the help video and tried to copy it . but now that i did it, his one works fine and the mine wont so can somebody help me !!! i want to get to the next world :frowning:

I see two problems:

  1. enemy.type == 'thrower', not 'trower'
  2. while enemy.health > 0, not while enemy.self.health >0:

I no need to do any code because I have thornprick :joy:.

Pls…
DO NOT WRITE IN A DEAD TOPIC
and it is 7years ago

1 Like

Hi @Faith_Kim , please don’t revive dead topics if what you’re saying is not directly related to the topic.
Thanks,
Marmite

3 Likes