Python Continue
Continue statement
The Continue statement is used in statements like for or while loop. If the condition is met, then you can use continue statement to continue the loop.
Examples
>>> x = 3 >>> for c in range(1,8): if x == 3: print("My value is: ", c) continue print("Next value: ", c) My value is: 1 My value is: 2 My value is: 3 My value is: 4 My value is: 5 My value is: 6 My value is: 7 >>>
>>> y = 2 >>> for c in range(1,4): if y == 2: print("Y value: ", y) continue print("C value: ", c) Y value: 2 Y value: 2 Y value: 2 >>>
>>> x = 1 >>> y = 2 >>> z = 3 >>> for num in range(1,5): if x == 1: print("X: ", x) if y == 2: print("Y: ", y) if z == 3: print("Z: ", z) continue print("Num: ", num) X: 1 Y: 2 Z: 3 X: 1 Y: 2 Z: 3 X: 1 Y: 2 Z: 3 X: 1 Y: 2 Z: 3 >>>