# Trial Counter - Loop Issue

**URL:** <https://discourse.psychopy.org/t/trial-counter-loop-issue/28417>\
**Category:** Builder\
**Created:** [April 5, 2022, 6:50am UTC](https://discourse.psychopy.org/t/trial-counter-loop-issue/28417 "2022-04-05T06:50:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brett99](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/brett99/32/32216_2.png) [@Brett99](https://discourse.psychopy.org/u/Brett99)\
**Post date:** [April 5, 2022, 6:50am UTC](https://discourse.psychopy.org/t/trial-counter-loop-issue/28417/1 "2022-04-05T06:50:32Z")

</div>

**OS** : Mac OS 10.15.6  
**PsychoPy version** : StandalonePsychoPy-2021.2.3-macOS  
**Standard Standalone? (y/n)** y  
**What are you trying to achieve?:**  
I am trying to create a textbook that shows how many “tickets” someone has out of the 40 trials, but I am coming across this problem: it shows out of 9 trials (presumably because it is only showing the “trials” loop which has 9 conditions/trials). “trials1” has an nReps of 4 and “trial\_4” has an nReps of 1. So ultimately there are 36 “trials” and 4 “trial\_4” for a total of 40 trials. How can I adjust my textbox below to reflect that:

**What did you try to make it work?:**

> 'Tickets: ’ +str(trials1.thisN) + “/” + str(trials.nTotal)

**What specifically went wrong when you tried that?:**  
It shows (0/9) instead of (0/40)

 ![Screen Shot 2022-04-05 at 2.33.10 AM](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/9/a95d68cea6fcd8fdf9936bcdaebc0d202ab3ea32.jpeg)

---

<div class="post-metadata">

**Author:** ![Becca](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/becca/32/34260_2.png) [@Becca](https://discourse.psychopy.org/u/Becca)\
**Post date:** [April 5, 2022, 4:53pm UTC](https://discourse.psychopy.org/t/trial-counter-loop-issue/28417/2 "2022-04-05T16:53:18Z")

</div>

> [@Brett99](#):
>
> 'Tickets: ’ +str(trials1.thisN) + “/” + str(trials.nTotal)

Is there a reason you can’t use a custom counter?

1. Add a code component to your reward routine
2. in the Begin experiment tab set `nTickets = 0`
3. in the Begin routine tab use `nTickets += 1`
4. in your text use `$'Tickets: ’ + str(nTickets) + ‘/40’

---

<div class="post-metadata">

**Author:** ![Brett99](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/brett99/32/32216_2.png) [@Brett99](https://discourse.psychopy.org/u/Brett99)\
**Post date:** [April 5, 2022, 10:29pm UTC](https://discourse.psychopy.org/t/trial-counter-loop-issue/28417/3 "2022-04-05T22:29:57Z")

</div>

Thank you, Becca!
