continue — the polite skip
The problem...
You're looping through a sequence. Most items — you process. Some items — you want to skip.
Right now you have no clean way to do that. The loop runs everything, every time.
The idea!
continue skips the rest of the current iteration and jumps straight to the next one. The loop doesn't stop — it just moves on.
The syntax
for item in sequence:
if condition:
continue # skip — go to next iteration
# this runs only if continue wasn't triggered
Your first continue
word = "Bull"
for letter in word:
if letter == "u":
continue
print(letter)
# B
# l
# l
The loop hits "u" — continue fires — the print is skipped. The loop moves to the next letter and carries on.
What's really happening
Without continue:
# B → print
# u → print
# l → print
# l → print
With continue on "u":
# B → print
# u → continue → skip print → next iteration
# l → print
# l → print
The loop never stops. It just skips what you tell it to skip.
A real example
word = input("Enter a word: ")
for letter in word:
if letter == " ":
continue
print(letter)
Every space is skipped. Everything else prints. One condition. Clean.
Heads up!
continueskips the rest of the current iteration — not the whole loop- The loop keeps running — only that one iteration is cut short
continuealways works with a condition — alone it would skip everything- Everything after
continuein the same iteration is ignored
The mindset shift
Stop thinking: "I need to handle every item the same way."
Start thinking: "Some items don't deserve the full treatment — skip them."
What you should understand now
continueskips the rest of the current iteration- The loop continues normally from the next item
- Use it with a condition — to skip specific items, not all of them
- Everything after
continuein the same block is ignored for that iteration