Python – Continue:
In this tutorial, we will learn about the Continue statement in Python.
Continue Statement is used to take the control to top of the loop for next iteration leaving the rest of the statements in the loop without execution
Below is the similar example of a for loop:
>>> for i in range(10): ... if (i==4 or i ==8): ... continue ... print(i) ...
Below is the Output:
0 1 2 3 5 6 7 9
Below is another example where the printing of even numbers are ignored:
>>> for i in range(100,110): ... if i%2==0: ... continue ... print(i,' is an even number') ... else: ... print(i,' is an Odd number') ...
Below is the output:
101 is an Odd number 103 is an Odd number 105 is an Odd number 107 is an Odd number 109 is an Odd number