I have a loop with a conditional check at some point, is there a way that I can exit the current iteration if the condition is true but still continue looping.
dummy = ['One','Two','Three','Four','Five']
for i in dummy:
print('Stage 1')
if i == 'Three':
break
print('Stage 2')
This code gives me:
Stage 1
Stage 2
Stage 1
Stage 2
Stage 1
But I would like this:
Stage 1
Stage 2
Stage 1
Stage 2
--------
Stage 1
--------
Stage 1
Stage 2
Stage 1
Stage 2
The highlighted line shows that it skipped the second print statement for element 'Three'.
Thanks
You meant to use
continue
instead ofbreak
: