Sarven Shepherd (Python)[SOLVED]

Hey, for some reason my code wont work.

can you take a look please?
many thanks.

while True:
    enemies = hero.findEnemies()
    enemyIndex = 0

    # Wrap this logic in a while loop to attack all enemies.
    # Find the array's length with:  len(enemies)
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    # "!=" means "not equal to."
    if enemy.type != "sand-yak" and enemy.health > 0:
        # While the enemy's health is greater than 0, attack it!
        hero.attack(enemy)
        
    enemyIndex += 1
    pass
    # Between waves, move back to the center.
    hero.moveXY(40, 32)
    

You might want to put the while-loop inside the loop

It doesen’t say do an if statement.

I did that and it worked.

1 Like

how did i not see that lol?

thanks milton :smiley:

You’re welcome. Please mark the post that helped you solve your problem with a little :heavy_check_mark:

He/her already did that

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.