[SOLVED] Can't solve Sarven Shepherd


#1

I’ve been trying to solve this for weeks with no luck, and I’ve almost every single thing possible but it yielded the same results. If there’s something I’m doing wrong, please tell me.

# Use while loops to pick out the ogre

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":
        # While the enemy's health is greater than 0, attack it!
        while enemy.health > 0:
            hero.attack(enemy)
        pass

    # Between waves, move back to the center.
hero.moveXY(40, 32)

#2

The code will only iterate through a single time because you aren’t incrementing. Also, there is a structural problem. The line, while enemyIndex < len(enemies): is not inside the while True: loop (it should be).


#3

Thank you! I was able to solve the level.