Skipping a loop based on a slider response

I am trying to skip a loop based on a slider response.
The slider is set to choice and has two options

I have put in a code component which has this on the “end routine” tab. I did think about doing it on each frame but I want the participant to have the option to change their mind

if answer_num.getRating() > 1:
contineRoutine = False
answer_yes.finished = True

answer_yes is the name of the loop I wanted skipped.

I am sure it is very simple but i am struggling to make it work. There are no error messages but it does not skip that loop if I select “No”.

I think in order to break out of a loop you need to set loop_name.finished = True rather than continueRoutine = False. In the previous, loop_name refers to the name of your loop.

Thank you! I tried that:

But it still doesn’t skip the following routines in the loop if I select “No” which is 2 on the slider rating. I suspect there may be something about identifying the slider rating as a number?

Hi everyone,
I have come up with a workaround which is to skip the routine based on the slider response for each routine in the loop so I think the values etc., are registering but the code to skip the loop is not so any thoughts on that would be great!
Thanks
Wendy