Restarting loop midway

Hello, I can’t seem to figure out what’s going on here. I have 3 inner loops nested within an outer loop, and I want to make it so that if a condition is met in the 2nd inner loop, then the outer loop starts over.
Right now, in Begin Routine, I have : ncode2 = 0;
and in End Routine, I have :

if key_resp_5.keys == '1':
    ncode2 = neighbor1code
if key_resp_5.keys == '2':
    ncode2 = neighbor2code
if key_resp_5.keys == '3':
    ncode2 = neighbor3code
if not key_resp_5.keys:
    continueRoutine = False
    trials.finished = True
if ncode2 = '' or '0':
    continueRoutine = False
    trials.finished = True

I think the trials.finished is terminating the whole experiment? And, if I take trials.finished = True out, then I get the following error: object0.xlsx not found. The 3rd inner loop’s conditions file is $‘object’+str(ncode2)+’.xlsx’, so it seems like the outer loop is trying to continue on to the 3rd inner loop.

The object1.xlsx and object2.xlsx files are examples of the inner loop conditions files. In object1.xlsx there are 3 “neighbors”, and if this is shown in the second inner loop, participants will choose one of the neighbors and then advance to the third inner loop. But in object2.xlsx there is a “terminating” object, where they make no response but it is supposed to trigger the onset of a new trial, ie restart the outer loop.

Thank you for any help or feedback!!

object1.xlsx (8.7 KB)

object2.xlsx (8.7 KB)
Uploading: 3rdloop_conditions.png…

It doesn’t make sense to put continueRoutine = False in an End Routine tab. Metaphorically, that’s like telling someone they have to get off the ice rink while they’re returning their skates. The best way to skip further inner loops within an outer loop is to set nReps of the inner loops to 0 (via a variable)

Ah, ok , thank you–that makes sense. However (not sure if this pic failed to upload the first time) , the inner loop whose nReps i would like to set to 0 with a variable is also defined with a variable, and so it seems like I cannot set that inner loop to 0 since the error is occurring before that inner loop begins.

nReps for trials_4 is set to 1 not a variable.

What error is occurring when?