Nearby lessons

53 of 108

Python - Continue Statement

continue Statement

The continue statement skips the current iteration and moves to the next iteration.

The loop does not stop.

Syntax

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
No output captured.

Example 1 - continue Statement

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
0
1
2
3
4
6
7
8
9

Explanation

When i becomes 5, the continue statement skips that iteration.

The remaining iterations continue normally.

Example 2 - Print Odd Numbers

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
1
3
5
7
9

Example 3 - Print Even Numbers

🐍
main.py
Python 3 Runtime
Loading Editor...
Output Preview
0
2
4
6
8

Real World Usage of continue

The continue statement is useful for:

  • Skipping invalid records
  • Ignoring unwanted values
  • Filtering data

🧠 Test Your Knowledge

2 Questions

Progress: 0 / 2
Keep Going!Python - Pass Statement