# \[SOLVED\] Infinte Loop Detected Problem

**URL:** https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734
**Category:** Level Help
**Created:** [July 3, 2020, 2:44am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734 "2020-07-03T02:44:31Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)
#### Post date: [July 3, 2020, 2:44am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/1 "2020-07-03T02:44:32Z")

</div>

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?

 ![Screenshot 2020-07-03 at 11.28.11 AM](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/8/8485f38e35ff25946f7c70394b822eb4c36634c8.jpeg)

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 3, 2020, 3:24am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/2 "2020-07-03T03:24:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)
#### Post date: [July 3, 2020, 3:27am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/3 "2020-07-03T03:27:52Z")

</div>

Heres the Code

```python
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)
    

```

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 3, 2020, 3:28am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/4 "2020-07-03T03:28:50Z")

</div>

> [@weary](#):
>
> `pass`

After the pass you forgot to increase friendIndex with 1.

Andrei

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 3, 2020, 3:29am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/5 "2020-07-03T03:29:25Z")

</div>

> [@weary](#):
>
> ```python
> return #Commented out to stop infinite loop.
> return #Commented out to stop infinite loop.
> 
> ```

And you can delete those now.

Andrei

---

<div class="post-metadata">

### Author: ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)
#### Post date: [July 3, 2020, 3:32am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/6 "2020-07-03T03:32:17Z")

</div>

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

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 3, 2020, 3:33am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/7 "2020-07-03T03:33:57Z")

</div>

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

Andrei

---

<div class="post-metadata">

### Author: ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)
#### Post date: [July 3, 2020, 3:34am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/8 "2020-07-03T03:34:43Z")

</div>

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

---

<div class="post-metadata">

### Author: ![weary](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/weary/32/15122_2.png) [@weary](https://discourse.codecombat.com/u/weary)
#### Post date: [July 3, 2020, 3:35am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/9 "2020-07-03T03:35:38Z")

</div>

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

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 3, 2020, 3:37am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/10 "2020-07-03T03:37:52Z")

</div>

No problem! 🙂

Andrei

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)
#### Post date: [July 3, 2020, 3:37pm UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/11 "2020-07-03T15:37:52Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)
#### Post date: [July 4, 2020, 8:47am UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/12 "2020-07-04T08:47:43Z")

</div>



---

<div class="post-metadata">

### Author: ![1999\_Ford\_Mustang](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/1999_ford_mustang/32/25207_2.png) [@1999\_Ford\_Mustang](https://discourse.codecombat.com/u/1999_Ford_Mustang)
#### Post date: [September 29, 2021, 8:35pm UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/13 "2021-09-29T20:35:40Z")

</div>

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?”

---

<div class="post-metadata">

### Author: ![moonwatcher348](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/moonwatcher348/32/24126_2.png) [@moonwatcher348](https://discourse.codecombat.com/u/moonwatcher348)
#### Post date: [September 29, 2021, 8:51pm UTC](https://discourse.codecombat.com/t/solved-infinte-loop-detected-problem/22734/14 "2021-09-29T20:51:24Z")

</div>

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