简体   繁体   中英

How can I 'continue' the outer most for loop when an if statement is satisfied?

How can I jump to the next value (not the next val) when the condition is satisfied?

Example:

lines = iter(open('something.txt', 'r'))
for value in list:
    for val in value:
        for v in val
            if v == "!":
            #execute code
            #jump to next value      
            

Use break to stop the inner loop and go to next value :

lines = iter(open('something.txt', 'r'))
for value in lines:
    for val in value:
        if val == "!":
            break

From what I can see in the example, you can just break from the inner loop.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM