psychopy.org | Reference | Downloads | Github

Terminating or continuing loop by asking the subject

Hello :slight_smile: , I have two routines as below :

Practice

In the endPracticeOrNot routine I will ask the subject to press y or n to terminate practicing or re-do again.
I wrote the code below in the End Routine of endPracticeOrNot :

if endPracticeKeyboard.keys == 'y' :
    print('Yes')
    startPracticeAgain.finished = 0
else :
    print('No')
    startPracticeAgain.finished = 1

My condition works except startPracticeAgain.finished so it doesn’t not steer the startPracticeAgain loop. How should I write it?
Thanks for your helps.

Setting startPracticeAgain.finished to False has no effect. This variable is always False until the loop ends (either naturally (because it has reached its nReps number of repetitions), or because you set .finished to True to make it terminate early).

So just give that loop a large enough nReps value so that you can be sure that it will continue at least until you tell it to finish.

1 Like

@Michael Thanks for your explanations, So I check this and works like a charm.

if endPracticeKeyboard.keys == 'y' :
    startPracticeAgain.finished = True
else :
    pass

And put nReps to 3 :blush: