Ending loop conditionnally. While loop?

Hi Micheal,

Thanks for your answer. I didn’t find what I’m looking for in the forum.
The mouse works fine. I just want to stop/restart the selection routine when the wrong stimulus is chosen.
What I’m looking for is close to the following post:

Well… not all of it. My program is done except for the rejecting wrong answer part.
In which you explain:

OK. So stick with the experimental routine as described but then create two additional routines to follow it: one for error feedback and the other for your ratings and so on. You can select which one will be executed on each trial by inserting a code component and in the Begin Routine tab, putting some code to not continue with the routine, depending on the decision made. You then also need to wrap all three routines in another loop (i.e. nested inside your main loop). This loop isn’t linked to a conditions file. Just give it a large number of repetitions. i.e. this just makes the trial repeat until the correct selection is made. In the begin routine tabs, put something like this:

# for the error feedback routine:
if image_chosen == CorrectAns:
    continueRoutine = False # don't give error feedback for a correct trial

# for the rating routine:
if image_chosen != CorrectAns:
    continueRoutine = False # don't do the rating
else: # will do the rating,
    your_inner_loop_name.finished = True # and end the cycle of repeating this trial

For now my program doesn’t react when the wrong answer is selected. But I want an error feedback that goes with it.
I tried feedback msg = ’ ’ in each frame with a text component in the routine.

if image_chosen == CorrAnsV:
                thisExp.addData('correct', 'True')
                continueRoutine = False
        else:
                thisExp.addData('correct', 'False')
                msg = 'Error'
                continueRoutine = True
        break 

But no message shows. When I try it in the begin experiment tab the error message shows at all times.
I’m not sure where to go from here.