A continue statement is used within a for loop to skip the remainder of the current iteration. Essentially, the continue statement will simply skip to the next iteration.
A normal for loop that prints the current index i:
1
2
foriinrange(3):print(i)
1
2
3
0
1
2
The same for loop, with a conditional and a continue:
1
2
3
4
foriinrange(3):ifi==1:continueprint(i)
1
2
0
2
On the second iteration of the for loop (when i = 1), the continue statement stopped the current iteration and “continued” to the next.
Using the pass statement
As implied by the name, the pass state does nothing.
1
2
3
4
foriinrange(3):ifi==1:passprint(i)
1
2
3
0
1
2
This is most useful when defining placeholders for future code to satisfy the interpreter.