Python Continue Statement

Python Continue Statement is a jump statement which is used to skip execution of current iteration. After skipping, loop continue with next iteration. We can use continue statement with for as well as while loop in Python

Continue Statement :



Python Continue Statement Example :




a=0

while a<=5:
    a=a+1
    if a%2==0:
        continue
    print a
print "End of Loop"



output of above example  :




1
3
5
End of Loop


You can use the continue statement to avoid deeply nested conditional code, or to optimize a loop by eliminating frequently occurring cases that you would like to reject.

The continue statement causes a program to skip certain factors that come up within a loop, but then continue through the rest of the loop.


advertisement