Code360 powered by Coding Ninjas X Naukri.com. Code360 powered by Coding Ninjas X Naukri.com
continue Statement

Python continue statement

 

The continue statement in Python returns the control to the beginning of the while loop. The continue statement rejects all the remaining statements in the current iteration of the loop and moves the control back to the top of the loop.

 

The continue statement can be used in both while and for loops.

 

Syntax:

 

continue

 

Example:

 

i = 0
while i < 5:

    if i == 3:
        i += 1
        continue
    
    print(i)
    i += 1

 

output:

 

0
1
2
4