I have been stuck on the Sarven Shepherd level for about a week and I don’t understand why my code isn’t working! Below is what I have:
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)
enemyIndex += 1
pass
# Between waves, move back to the center.
hero.moveXY(40, 32)
I have tried several variations of this code, changing the indent level in front of “enemyIndex += 1” and wrapping the entire second while loop within the while True loop, but my character never moves or does anything. If anyone has any advice I would really appreciate it!