← Back to Blog

pass / continue / break — The Full Picture

The idea!

You've covered pass, continue, break, and for...else.

This is your reference. Everything in one place.

Come back here whenever you need a reminder.

pass — the silent keeper

Does nothing. Holds the space.

for letter in "Bull":
    pass    # valid — no error, no output

if score >= 60:
    pass    # placeholder — come back later

Use it when Python requires a block but you're not ready to fill it in yet.

continue — the polite skip

Skips the rest of the current iteration. Loop keeps going.

for letter in "Bull":
    if letter == "u":
        continue    # skip "u", move to next
    print(letter)

# B / l / l

break — the emergency exit

Stops the loop immediately. No more iterations.

for letter in "Bull":
    if letter == "u":
        break    # stop everything
    print(letter)

# B

for...else

else runs when the loop completes without break. Skipped if break fired.

for letter in "Bull":
    if letter == "x":
        break
else:
    print("No x found.")    # runs — loop completed without break

# No x found.

Search pattern — the classic use case

word = input("Enter a word: ")
target = input("Enter a letter: ")

for letter in word:
    if letter == target:
        print(f"Found '{target}'.")
        break
else:
    print(f"'{target}' not found.")

The three in one block

for letter in "RedHorn":
    if letter == "d":
        pass             # placeholder — handle later
    if letter == "e":
        continue         # skip "e"
    if letter == "R":
        break            # stop at "R" — wait, R is first
    print(letter)

Each one does something different. None of them are interchangeable.

Common Mistakes

  • pass does nothing — don't use it when you mean continue
  • break always needs a condition — alone it stops on the first iteration
  • else is skipped when break fires
  • continue and break only work inside loops

What you should understand now

  • pass — does nothing, holds the space
  • continue — skips the current iteration, loop keeps going
  • break — stops the loop entirely
  • for...elseelse runs only when loop completes without break
  • Three different tools. Three different jobs. Not interchangeable.
[ login to bookmark ] // copied! 22 views · 1 min
// resources
Cheatsheet pass / continue / break — The Full Picture
← prev Common PASS/CONTINUE/BREAK Mistakes next → Let Python roll the dice
// 0 comments
// No comments yet. Be the first.
// leave a comment

// Your comment will appear after approval.