# Psychopy Loop - Terminating the loop

**URL:** <https://discourse.psychopy.org/t/psychopy-loop-terminating-the-loop/34268>\
**Category:** Builder\
**Created:** [April 5, 2023, 5:49pm UTC](https://discourse.psychopy.org/t/psychopy-loop-terminating-the-loop/34268 "2023-04-05T17:49:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TTT](https://avatars.discourse-cdn.com/v4/letter/t/d07c76/32.png) [@TTT](https://discourse.psychopy.org/u/TTT)\
**Post date:** [April 5, 2023, 5:49pm UTC](https://discourse.psychopy.org/t/psychopy-loop-terminating-the-loop/34268/1 "2023-04-05T17:49:39Z")

</div>

**OS** (e.g. Win10): Win11  
**PsychoPy version** (e.g. 1.84.x): PsychoPy 2022.1.4  
**Standard Standalone? (y/n)** If not then what?: yes  
**What are you trying to achieve?:**  
I am creating an experiment where a new type of sound stimuli is presented after every 10 sound stimuli.

**What did you try to make it work?:**  
I have created two loops and use the code to terminate the first loop to continue the routine for the second loop:  
myCount = myCount + 1  
if myCount \> 9:  
myCount = 0  
Loop1.finished = True

**What specifically went wrong when you tried that?:**  
I want all stimuli in the list are represented sequentially, but they kept looping the first 10 stimuli. How can I run through the whole stimuli list in this design? Thank you very much!

---

<div class="post-metadata">

**Author:** ![JensBoelte](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/jensboelte/32/9060_2.png) [@JensBoelte](https://discourse.psychopy.org/u/JensBoelte)\
**Post date:** [April 28, 2023, 11:26am UTC](https://discourse.psychopy.org/t/psychopy-loop-terminating-the-loop/34268/2 "2023-04-28T11:26:08Z")

</div>

Hello TTT

change your code to

```auto
myCounter += 1

if myCounter > 9:
    myCounter = 0
    continueRoutine = True
else:
    continueRoutine = False

```

Best wishes Jens
