Python Continue Statement

The continue statement is similar to the break statement. When continue statement is executed, it stops the current iteration of the loop and continue with the next iteration of the loop.

If we execute a continue statement inside a for loop, the control transfers control back to the top of the loop and the variable is set to the next value.


Syntax of Continue Statement

for variable in sequence condition: continue statements

Example of Continue Statement in For Loop

>>> for n in range(1, 10):
	if(n == 5):
		continue
	print(n)

	
1
2
3
4
6
7
8
9


Python continue statement

Output of the above code

Python continue statement



Example of Continue Statement in While Loop

>>> while i < 90:
	i = i + 3
	if(i % 7) == 0:
		continue
	print i,

	
24 27 30 33 36 39 45 48 51 54 57 60 66 69 72 75 78 81 87 90






Read more articles


General Knowledge



Learn Popular Language