continue Statement
Imagine you are checking a bag of apples. You find one with a bruise, so you skip it and move to the next one. You don't throw away the whole bag! In Python, we use the continue statement to do exactly that—skip one part and keep going.
What is the Continue Statement?
The continue keyword tells Python to skip the current step of a loop and jump straight to the next one. Unlike break, it does not stop the loop completely.
It is the perfect tool for filtering data or ignoring specific values that you don't want to process.

Real-World "Continue" Scenarios
-
Attendance: Check a list of students, but skip those who are absent.
-
Math Filters: Print all numbers from 1 to 10 but skip the negative ones.
-
Scheduling: Create a work plan but skip Saturdays and Sundays.
-
Cleaning: If you are sorting toys, skip the broken ones and keep sorting the rest.
How it Looks (Syntax & Examples)
The Pattern:
for item in list:
if condition:
continue # The "Skip" Button
Example 1: The Missing Number
If we tell a loop to count to 5 but put a continue at 3:
for i in range(1, 6):
if i == 3:
continue
print(i)
Output: 1, 2, 4, 5
Example 2: The While Loop Filter
i = 1
while i <= 5:
i += 1
if i == 3:
continue
print(i)
Output: 2, 4, 5, 6
Summary:
-
-
Partial Skip: It only skips one iteration, not the whole loop.
-
Filtering: It's the best way to ignore unwanted values like empty spaces or errors.
-
Stay Active: Use it when you want the loop to keep running until the very end.
-