A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-continue-statement/ below:

Python Continue Statement - GeeksforGeeks

Python Continue Statement

Last Updated : 12 Jul, 2025

Python continue statement is a loop control statement that forces to execute the next iteration of the loop while skipping the rest of the code inside the loop for the current iteration only, i.e. when the continue statement is executed in the loop, the code inside the loop following the continue statement will be skipped for the current iteration and the next iteration of the loop will begin.

Example:

Python
for i in range(1, 11):
    if i == 6:
        continue
    print(i, end=" ")

Explanation: When i == 6, the continue statement executes, skipping the print operation for 6.

Syntax

while True:
...
if x == 10:
continue
print(x)

Parameters : The continue statement does not take any parameters.

Returns: It does not return any value but alters the flow of the loop execution by skipping the current iteration.

Examples of continue statement

Example 1: Skipping specific characters in a string

Python
for char in "GeeksforGeeks":
    if char == "e":
        continue
    print(char, end=" ")

Explanation: Whenever char == 'e', the continue statement executes, skipping the print function for that iteration.

Example 2. Using continue in nested loops

Python
a = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]

for row in a:
    for num in row:
        if num == 3:
            continue
        print(num, end=" ")

Explanation: continue statement skips printing 3 and moves to the next iteration, so all numbers except 3 are printed in a single line.

Example 3. Using continue with a while loop

Python
i = 0
while i < 10:
    if i == 5:
        i += 1  # ensure the loop variable is incremented to avoid infinite loop
        continue
    print(i)
    i += 1

Explanation: When i == 5, the continue statement skips printing and jumps to the next iteration.

When to Use the Continue Statement?

We should use the continue statement when we need to control the flow of loops efficiently by skipping specific iterations while still executing the rest of the loop. Here are some key scenarios:

For more loop control statements, refer to:



RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4