I’m curious about why something doesn’t work.
Below is the code that did work. My question is why isn’t “while enemyIndex < len(enemies):” substitutable with “while enemyIndex < 3”?. There are 6 enemies so from my understanding after the third shaman is killed enemyIndex would = 3 and len(enemies)=3, which is why the first code works. By this logic “enemyIndex < 3” should be equal to "enemyIndex < len(enemies). My character just stands still instead of entering the loop.
enemyIndex = 0
# Wrap this section in a while loop to iterate over all enemies.
enemy = enemies[enemyIndex]
while enemyIndex < len(enemies):
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
while enemy.health > 0:
self.attack(enemy)
enemyIndex += 1