HELP! Lurkers! Nothing happens!

enemies = hero.findEnemies()
enemyIndex = 0
while enemyIndex < len(enemies):
    enemy = enemies[enemyIndex]
    if enemy.type == 'shaman':
        while enemy.health > 0:
            hero.attack(enemy)
    enemyindex = enemyindex + 1

My hero does nothing!!

you have enemyIndex twice

My code changed but it does not work.

enemyIndex = 0
if enemy.type == 'shaman':
    enemies = hero.findEnemies()
    while enemy.health > 0:
        hero.attack(enemy)
    enemyIndex += 1
enemies = hero.findEnemies()
enemyIndex = 0
while enemyIndex < len(enemies):
    if enemy.type == 'shaman':
        while enemy.health > 0:
            hero.attack(enemy)
    enemyindex = enemyindex + 1

That’s a good thing… bruh

reset your code back to what it was

I am going off what my code is

This never assigns, it only reads…

It won’t load!!
Screenshot 2022-06-29 9.07.12 AM

Click on “comment out my code” twice and then it should load, and I know your mistake

1 Like

What Moonwatcher said. Comment out your code twice. Then here are some things I noticed.

enemyIndex = 0
if enemy.type == 'shaman': #At this point in the code, enemy is not defined. You'll need to define it. Maybe a for-loop or a while-loop.
    enemies = hero.findEnemies() #enemies isn't used in this conditional. You don't need this line.
    while enemy.health > 0: #Again, enemy is not defined.
        hero.attack(enemy) #Same enemy thing
    enemyIndex += 1
#Actually, this whole part of this code is a duplicate of below.
enemies = hero.findEnemies()
enemyIndex = 0 #enemyIndex is already defined. You normally want to stay away from defining things twice.
while enemyIndex < len(enemies):
    #you need to add an enemy variable here (enemy = enemies[enemyIndex]).
    if enemy.type == 'shaman':
        while enemy.health > 0:
            hero.attack(enemy)
    enemyindex = enemyindex + 1

You forgot to add the enemy thing on the lines in the while loop, and enemyindex and the end needs to have a capital i… and preferably use +=

1 Like

Still nothing happens!

Never mind I did it!

Please mark the post that was the solution as the solution, not just yours :/

2 Likes

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.