Skip to main content

Python, break out of nested loops

Use raise StopIteration:
try:
for loop:
for loop:
for loop:
if condition:
raise StopIteration()
except StopIteration
pass

Comments