Search code examples
pythonfor-loopbreakcontinue

Is there any way to use continue on a loop that im not in?


for i in range(10):
   for j in range(10):
      if somecondition:
          continue

--> here I want to continue the loop with for i in range(10), not the j loop. Is there any way I can do that?


Solution

  • You can use break to exit the nested loop. For example

    for i in range(10):
       for j in range(10):
          if somecondition:
              break