-3

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      
            
General Grievance
  • 4,555
  • 31
  • 31
  • 45

2 Answers2

1

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
Corralien
  • 109,409
  • 8
  • 28
  • 52
1

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

Pietrek
  • 66
  • 6