# Resetting the accuracy after each round and ending after certain repetation on practice

Hi everyone,

I am currently working on a research project in PsychoPy and have a question on how to deal with a problem related to practice trials.

So the design is as follows: There are three practice rounds. Each round has ten items that are randomly tested. If the participant reaches 80% or higher accuracy in a round (= 8 or more out of 10 items correct), they are done with the practice rounds and sent directly to the experiment. So they don’t necessarily have to do all the three practice rounds. If, however, they do not manage to reach 80% in the first, second and third round, the experiment is paused and the experimenter has the chance to explain the experimental paradigm again. After that, another set of three practice rounds should start. With regard to programming, I haven’t found out how to reset the number of correct answers in between the three rounds, so that after the second round it’s not 80% out of the 20 items altogether out of the 1st and 2nd practice rounds, but only out of the 10 items in the second practice round (and the same for the third round).

In the PsychoPy Builder I have added these lines of simple code in the Begin Experiment and End Routine Tab:

Begin Experiment:
`total_acc = 0`

End Routine:
`if (keyTraining.corr == 1):`
`total_acc = total_acc + 1`
`else:`
`total_acc = total_acc + 0`

`if (total_acc >= 8):`
` Trainingloop.finished = True`

I hope my question is clear. Feel free to ask me, if it is not clear.

Thank you very much!

Would the following help?

``````total_acc += keyTraining.corr

if (total_acc >= 8):
Trainingloop.finished = True
total_acc = 0
``````

Hi,

Thank you so much for your quick reply. I’ve tried your suggestion, but the sum of correct answers doesn’t reset between rounds and just continues to add up. The result is that sometimes in rounds 2 or 3, when the target accuracy of 8 is reached (out of all items), the experiment just stops in the middle of a round…