Conditions to end routine

Hello,

I have a code component that ends the routine when the score is at 8:

score+=key_resp_learn.corr
thisExp.addData(‘Score’,score)
if score >= 8:
learning_trials.finished = True

This means the participant has answered correctly 8 times overall. I would like to make it so that when the participant has answered correctly 8 times in a row, the routine ends. How would I change the coding that I have to make that possible?

Thanks,
Mary

You could use the same technique I suggested in answer to your other question, only rather than storing the stimulus value in a list, storing correct.

You can then test whether the last 8 values in the list are all correct using:

all(wasCorrectList[-8:])

This will be True when every value from the -8th (8th to last) value to 0th value (beginning/end of array) is True