[SOLVED] Sarven desert Shepard help

while True:
    enemy = hero.findEnemies()
    enemyIndex = 1

    # Wrap this logic in a while loop to attack all enemies.
    # Find the array's length with:  len(enemies)
while True:
    
    enemies = self.findEnemies()
    enemyIndex = 0
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
        if enemy:
            if enemy.type != "sand-yak":
                while enemy.health > 0:
                    hero.attack(enemy)
hero.moveXY(40, 32)

You can’t have 2 while loops. Delete the first one.

I deleted the first while true loop

and it does not work

You forgot the increment of index. Make sure to include it the while true loop.

it is saying that there is a unknown binary uadd

Can you take a screenshot of the error?

Delete the first while true loop. And delete the spaces in front of the enemyIndex and hero.findEnemies()

Try deleting the lines that starts with #

I did but it still says it

The increments of the enemyIndex is wrong, you put it with the hero.moveXY line.

did that and it is still saying it

Can you copy and paste the code here?

    
enemies = self.findEnemies()
enemyIndex = 0
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy:
        if enemy.type != "sand-yak":
            while enemy.health > 0:
                hero.attack(enemy)
                
    hero.moveXY(40, 32)
    enemyIndex =+ 1

It’s suppose to be enemyIndex += 1 not the opposite around.

1 Like

thank you it works now

1 Like

Anytime :slight_smile:

it works for the first but then the rest the character does not work