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

Lurkers help please [SOLVED]

Whenever I run the code it says something like “cannot read type undefined” and highlights this code

if enemy.type == "shaman":

This is the rest of the code, and thank you in advance to anyone who tries to help me

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

It’s because of this line:

while enemyIndex < enemies:

look back at the older levels where they explain how to do while loops and learn it again.
Danny

any levels in particular?

nevermind, thanks!

[en_US.composer.my_button_text]