Feedback showing cumulative scores after every 20 trials

PsychoPy version (e.g. 1.84.x): v2021.2.3
What are you trying to achieve?: show feedback every 20 trials (overall 80), showing cumulative score

What did you try to make it work?: I have lines that run smoothly to show cumulative scores on single trials if they are ‘correct’. Not sure how to show feedback ONLY after every 20 trials.

This is what I have in begin routine:
ThisCorrectCount = (CorrectCount+1)
if abs(netxlocation-coinxlocation) <=.024:
feedback = ‘Correct!’
feedback2 = str(ThisCorrectCount) + ’ Trials Correct’
feedback = ‘’
feedback2 = ‘’

Thanks in advance!

Make your code conditional on the trial number (here check that it is a multiple of 20 by seeing that the remainder is 0 when dividing by 20, remembering to add 1 first as they count from 0):

if (your_loop_name.thisN + 1) % 20 == 0 and abs(netxlocation-coinxlocation) <=.024:
1 Like

(post deleted by author)

@Michael Hi Michael! Thanks for your help!
I tried: if (your_loop_name.thisN + 1) % 20 == 0,
continueRoutine = False
However, it stops every trial instead of every 20 trials…

I tried this and it works:
if TrialCounter == 0 or TrialCounter % 20 != 0:
continueRoutine = False

BUT, for the first round, it would stop at 19 trials, and then every 20 trials. Do you perhaps know how to fix it? Thanks a lot!

Hi, could you format your code rather than just pasting it in as raw text? You can do this by clicking the button in the toolbar of the post that looks like this: </>, or manually by putting three ``` symbols on a line before and after your code. I can see a possible reason why your first snippet wouldn’t work, but can’t be sure unless I can see it properly formatted with indents and everything.