break and continue Statements

The break and continue statements are used to control the flow of loops in Python.

🔁 These statements work inside loops only.

break Statement

The break statement stops the loop immediately.

for i in range(1, 6):
    if i == 3:
        break
    print(i)

continue Statement

The continue statement skips the current iteration and moves to the next one.

for i in range(1, 6):
    if i == 3:
        continue
    print(i)

Difference Between break and continue

  • break exits the loop
  • continue skips one iteration
❌ Misuse can make loops hard to understand.

Practice

  1. Stop a loop when number becomes 7
  2. Skip printing even numbers