If this template helps then use it. If not then just delete and start from scratch.
**PsychoPy version: 3.2.4
**Standard Standalone? (y)
In my experiment, a participant has to complete 3 randomized blocks of 12 trials each. I want to make it so that participants must get at least 90% of the trials in the last block correct before they can finish. If the participant gets less than 90% correct in the last block, they have to do the entire experiment over again.
I’ve almost gotten it to work by making the second loop’s nReps=2 and using this code:
ACQkeyRespcorrs =  minNrPractice = 36 # min number of trials to practice considerNrTrials = 12 # number of trials to consider for accuracy calculation minAccuracy = 0.9
respcorrs.append(resp.corr) # assumes your keyboard component is called "ACQkeyResp" if len(respcorrs) >= minNrPractice: respcorrsRecent = respcorrs[-considerNrTrials:] respcorrsSum = sum(respcorrsRecent) # only works if error=0 and correct=1 accuracy = float(respcorrsSum)/considerNrTrials if accuracy >= minAccuracy: break
However, when >=90% accuracy is achieved at the end of the third block, one trial from Block 1, 2, 3 follow before the experiment ends. How can I get the extra three trials not to run?