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 < 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)
This line is currently a member of the ‘while enemy.health’ loop. This means that it will keep incrementing on every iteration of that loop. Instead, move it so that it is the final statement of the outer ‘while enemyIndex’ loop.
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 < 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)
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 < 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)
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 < 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)