# Sarven Shepherd Infinite Loop problem

I’m trying to complete Sarven Shepherd but my code keeps ending up in an infinite loop of not doing anything. Could somebody help?
Code:

``````# Use while loops to pick out the ogre
while hero.time < 120:
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)

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

``````

Code when commented out:

``````return  #Commented out to stop infinite loop.
# Use while loops to pick out the ogre
while hero.time < 120:
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)

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

``````

All it seems to do is add the first line.

The game automatically comments out your code because it wouldn’t be able to open the page without doing that due to the infinite loop.

Your code is supposed to be looping through an array. Each time it iterates through the loop it’s supposed to increment by 1. Without the increment, you get an infinite loop.

Oh. Whoops! I’ll fix it.