Ad

How Can I Jump To Another Loop?

I have a problem. I don't know how to jump to another loop. Should I use 'continue' or 'break' in the current loop? (python3.x)

While True: <-- continue to this

While True:

continue <-- continue to the first while loop

Ad

Answer

The break key word allows you to exit the presiding loop you are in. So if you have a statement like:

while True:
    while True:
         break

The break will send you back to the first loop.

Ad
source: stackoverflow.com
Ad