Level: Preferential Treatment - Help!


#1

I can’t figure out how to solve it. I’m doing the classroom version. It skip[s to the second loop. My code is:

# First, loop through all enemies...
enemies = self.findEnemies()
enemyIndex = 0
while enemies.len > enemyIndex:
# ... but only attack 'thrower' type enemies.
    if enemies[enemyIndex].type =='thrower':
        while enemies[enemyIndex].health>0:
            self.attack(enemies[enemyIndex])
    enemyIndex = enemyIndex + 1;
# Then loop through all the enemies again...
enemies = self.findEnemies()
enemyIndex = 0
while enemies.len>enemyIndex:
    # ... and take out everyone who's still standing.
    while enemies[enemyIndex].health > 0:
        self.attack(enemies[enemyIndex])
    enemyIndex = enemyIndex + 1;

#2

Please read the FAQ before posting again. You must learn how to format your code. I’ve done it for you this time.

You appear to be using Python. Please correct me if I’m wrong. Python does not require the use of semicolons, so remove those. Also, your calling of len is wrong. The proper way is len(enemies).


#3

okay my classroom uses python and im used to js