[SOLVED] Infinte Loop Detected Problem

Hi, I was trying to open Sarven Shepherd level in dessert an infinte loop detected screen appeared, what does it mean, can anyone solve it?

1 Like

Try to press the button Comment put my code to get your code then copy it and then press on Restart level and reloaad the window and then paste the code, but if you can post it here so I will be able to help you get rid of the infinite loop.

Andrei

Heres the Code

return  #Commented out to stop infinite loop.
return  #Commented out to stop infinite loop.
# Use while loops to pick out the ogre

while True:
    enemies = hero.findEnemies()
    enemyIndex = 0

    # Wrap this logic in a while loop to attack all enemies.
    # Find the array's length with:  len(enemies)
    while enemyIndex < len(enemies):
        enemy = enemies[enemyIndex]
    # "!=" means "not equal to."
        if enemy.type != "sand-yak":
        # While the enemy's health is greater than 0, attack it!
            while enemy.health > 0:
                hero.attack(enemy)
        pass

    # Between waves, move back to the center.
    hero.moveXY(40, 32)
    
1 Like

After the pass you forgot to increase friendIndex with 1.

Andrei

1 Like

And you can delete those now.

Andrei

1 Like

Tysm it worked and btw is there any items for wizards that deals huge knockback because I’m currently on bash’em all and nothing seems to work

1 Like

You can try to do that level with a warrior and a shield that has bash.

Andrei

I know but I spend most of my gems Nalfar and honestly dont wanna spend anymore on wizards because I barely use them

1 Like

I’ll try then (20 chars) Thanks for the Help :smiley:

1 Like

No problem! :slightly_smiling_face:

Andrei

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

I have the infinite loop problem on level 24 of Game development 2, and when I try to press any buttons, it freezes up and a notification says “CodeCombat isn’t responding, do you want to close the tab?”

Contact support and ask them to reset your code @1999_Ford_Mustang.