[SOLVED] Lurkers level help (python)

CodeCombat - Coding games to learn Python and JavaScript?

this is the level link

why does it say
UAdd

1 Like

checking now give me a sec

can you send me your code so i can check it

ok 1 sec lemme get the code

# findEnemies returns a list of all your enemies.
# Only attack shamans. Don't attack yaks!
while True:
    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 enemy < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy.type == 'shaman':
        while enemy.health > 0:
            hero.attack(enemy)
# Remember to increment enemyIndex
enemyIndex =+ 1

thanks i will give you the results in a sec

remove the while true loop and it should work

ok ill try it (i hate 20 char rule)


same thing, it still says UAdd

hmm can you send me your new code

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

Its not =+, its +=. Thats why its not working. Hope this helps!

nope doesnt work it just removes the problem

can you send us your new code

tip:
put the increments inside the loop
Like this:

# findEnemies returns a list of all your enemies.
# Only attack shamans. Don't attack yaks!
#indent everything and put it in a loop
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 enemy < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy.type == 'shaman':
        while enemy.health > 0:
            hero.attack(enemy)
            enemyIndex += 1
# Remember to increment enemyIndex
# enemyIndex += 1 wrong place
enemyindex += 1

needs to be in the while loop