Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help with Lurkers

Hey Ive been stuck on this level awhile guess i need more help than i thought heres my code:

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
enemyIndex < enemyDistance
enemy = enemies[enemyIndex]
if enemy.type == 'shaman':
    while enemy.health > 0:
        hero.attack(enemy)
# Remember to increment enemyIndex
enemyIndex + 1

Hi @SpunkyDaSpider, welcome to the CodeCombat discourse!
There are a two problems here.
The first one is you need to “wrap” you code from line 6 in a while loop otherwise it won’t happen more than once (there are multiple shamans so you’ll need to run this code multiple times.
While checks if something is true e.g.

while temperature < 0: 
    hero.say("It's freezing!")

You need to check that enemyIndex < the length of the enemies. Now that brings us neatly onto the second problem.
Your code for line 6 is:

Obviously you’ll have to do what I said above, but there’s another problem…
Read this comment carefully:

# While the enemyIndex is less than the length of enemies

Can you see it?
I hope this helps
Danny

thanks for the help i guess my brain was off :grinning: