Help sarven shepherd

I don’t understand how to find the array’s length with: len(enemies) so I cannot finish this level and continue my quest! Please teach me how!!!

Hi @Eddy_375.
Please could you post your code for that level (formatted using triple ``` at the start and end of you code) onto the forum so we can see where you’re going wrong.
Thanks,
:lion: :lion: :lion:

1 Like

Hello,

To break it down, “enemies” is an array that holds a list of the enemies. When len() is placed around an array, it will count the number of enemies (in this case) in the array and return a number value. The number value returned from len(enemies) allows you to compare it to other number values like an index to use in a for/while loop.

Hi brooksy125! Welcome to Code Combat Discourse!

Eddy_375,
You don’t know the length of the array so in the pre-written starter code, you start off with enemyIndex = 0. Then you write a while loop, while enemyIndex is less than the length of enemies, do something. In this case, you attack an enemy. Once you’ve killed the enemy, you increment the enemyIndex by one. Then you start over, only now the enemyIndex is equal to one. If one is not less than the length of the array, you’re done. If it is less, the code iterates through again.