If you're able to extract the loop code into a function, a return
statement can be used to exit the outermost loop at any time.
def foo():
for x in range(10):
for y in range(10):
print(x*y)
if x*y > 50:
return
foo()
If it's hard to extract that function you could use an inner function, as @bjd2385 suggests, e.g.
def your_outer_func():
...
def inner_func():
for x in range(10):
for y in range(10):
print(x*y)
if x*y > 50:
return
inner_func()
...