| Reference | Downloads | Github

Run loop a limited number of times

If this template helps then use it. If not then just delete and start from scratch.

Win10 (e.g. Win10):
PsychoPy version 2021.1.4 (e.g. 1.84.x):
Standard Standalone? (y) If not then what?:
What are you trying to achieve?:
I have a csv file with around 120 sentences in 2 conditions. The experiment should become a single-trial experiment, meaning each participants reads only two sentences one of condition a and one of condition b.
So P1, reads A1, B1; P2: A2 B2, …

What did you try to make it work?:
I tried to work it out through the nRep function but it did not work. Also I tried to include two loops, one for each condition.

What specifically went wrong when you tried that?:
Every sentence in the csv file of condition A was shown, the same in csv for condition B.

To run a loop only once put nReps as 1 but then add loopName.finished=True in a code component inside the loop (End Routine or Begin Routine).

Thank you for your timely response.
If I put it at the end of the loop the sentence only occurs ones but than it breaks down due to:

NameError: name 'loopName' is not defined
##### Experiment ended. #####

And then just one sentence is shown, but I do need one of each condition to be shown.
If I put nRep=2, it breaks down, too.

What is your loop called?

just “trials”
It contains 2 routines: the sentence and a question.

I assume that you tried trials.finished=True and then it worked.