I’ve written my code for this level over and over, but it won’t work, and I can’t find out what’s wrong. There are no error messages, the hero just completely ignores my while loop.
I’ve posted my code here in hope that someone can please help me! Thank you!
# This array contains friends and ogres. # The even elements are ogres, but the odds are friends. everybody = ['Yetu', 'Tabitha', 'Rasha', 'Max', 'Yazul', 'Todd'] enemyIndex = 0 while enemyIndex < len(everybody): # Use square brackets to get the ogre name from the array. enemy = everybody[enemyIndex] # Attack using the variable holding the ogre name. if enemy: while enemy.health > 0: self.attack(enemy) # Increment by 2 to skip over friends. enemyIndex += 2 # After defeating ogres, move to the oasis. self.moveXY(36, 54)