Hello, I am new to these forums, so sorry if this is a duplicate…
I need help on the Lurkers level in the desert biome.
My hero just stands there doing nothing, and after a while, the ducky appears with the error
“Code never finished. It’s either really slow or it has an infinite loop.”
Here is my code:
# findEnemies returns a list of all your enemies.
# Only attack shamans. Don't attack yaks!
enemies = hero.findEnemies()
enemyIndex = 0
# Wrap this section in a while loop to iterate all enemies.
# While the enemyIndex is less than the length of enemies
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
hero.attack(enemy)
enemyIndex += 1
# Remember to increment enemyIndex
Thanks if you can help!