Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Lesson 09

continue Statement — Skip to Next Iteration

Use Python continue in for and while loops to skip the rest of the current iteration. Filter vowels, skip characters, and keep the loop else block behavior.

Beginner25 min

continue statement

  • continue is a keyword.
  • continue sends PVM to the top of the loop without executing statements after continue for the current iteration only.
  • Must be used inside loops.
  • When continue is used, the else part of the loop still executes if the loop condition eventually becomes false (unlike break).

Syntax — continue in for loop

python
for varname in iterable_object:
    if test_cond:
        continue
    statement_1   # skipped this iteration when continue runs
    statement_2

Syntax — continue in while loop

python
while test_cond:
    if test_cond:
        continue
    statement_1
    statement_2

Example 1 — Skip 'T' in for loop

python
s = "PYTHON"
for ch in s:
    if ch == "T":
        continue
    else:
        print(ch)
else:
    print("for loop---else part")

Example 2 — Skip 'H' and 'Y' in while loop

python
s = "PYTHON"
i = 0
while i < len(s):
    if s[i] == "H" or s[i] == "Y":
        i = i + 1
        continue
    print(s[i])
    i = i + 1
else:
    print("while..else part")

Example 3 — Print consonants only

python
line = input("Enter a Line of Text:")
for ch in line:
    if ch.lower() in ["a", "e", "i", "o", "u"]:
        continue
    else:
        print(ch, end="")

continue vs break

break continue
Loop else Skipped Still runs if loop ends normally
Current iteration Stops loop Skips remaining statements
Next step Exit loop Next iteration

Next: File 10 — pass Statement

Loading playground…