Python Mastery – From Basics to Brilliance / Control Flow & Decision Making

break, continue, pass

These special keywords help control what happens inside loops:

Keyword

What It Does

break

Stops the loop immediately

continue

Skips the current iteration and moves to the next

pass

Does nothing — used as a placeholder when code will be added later


🔸 break

for i in range(1, 6):
    if i == 3:
        break  # Stop the loop when i is 3
    print(i)

🔸 continue

for i in range(1, 6):
    if i == 3:
        continue  # Skip this iteration when i is 3
    print(i)

🔸 pass

for i in range(5):
  if i == 2: pass # Will pass when i == 2
  print(i)

📝 pass is useful when you're still writing your program and need to leave a "to-do" in the structure without causing a syntax error.