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