# 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)
length = 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
else:
# Between waves, move back to the center.
hero.moveXY(40, 32)
length = 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
else:
# Between waves, move back to the center.
hero.moveXY(40, 32)
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 True:
length = 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
else:
# Between waves, move back to the center.
hero.moveXY(40, 32)
I’m replying to your first post following the logic of your program. Main problem is the indentation and you must increment the enemyIndex. So after length = len(enemies)
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type != "sand-yak":
while enemy.health > 0:
hero.attack(enemy)
else:
hero.moveXY(40, 32)
enemyIndex += 1
all this in the main while True loop. You were very close