Break vs Continue in Python

Both break and continue are jump statements used inside loops in Python. But they behave differently:

  • break: Immediately exits the loop.
  • continue: Skips the current loop cycle and moves to the next iteration.

Example 1: Using break

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

Output:

1

2

Explanation:

  • Loop starts from 1 to 5.
  • When i == 3, break runs → loop stops completely.
  • So, 3, 4, and 5 are not printed.

Example 2: Using continue

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

Output:

1

2

4

5

Explanation:

  • The loop runs from 1 to 5.
  • When i == 3, continue runs → it skips printing 3 and moves to the next number.
  • All other values are printed normally.

Quick Comparison Table:

Feature break continue
Used to Exit the loop early Skip current iteration
Loop status Stops completely Continues with next value
Can be used in for, while for, while
Example output 1, 2 (then stops) 1, 2, 4, 5 (3 skipped)

Summary:

  • break is used when you want to exit the loop completely.
  • continue is used to skip the current loop step and move to the next one.
  • Both are helpful for controlling how and when loops run.

Welcome to ShikshaSanchar!

ShikshaSanchar is a simple and helpful learning platform made for students who feel stressed by exams, assignments, or confusing topics. Here, you can study with clarity and confidence.

Here, learning is made simple. Notes are written in easy English, filled with clear theory, code examples, outputs, and real-life explanations — designed especially for students like you who want to understand, not just memorize.

Whether you’re from school, college, or someone learning out of curiosity — this site is for you. We’re here to help you in your exams, daily studies, and even to build a strong base for your future.

Each note on this platform is carefully prepared to suit all levels — beginner to advanced. You’ll find topics explained step by step, just like a good teacher would do in class. And the best part? You can study at your pace, anytime, anywhere.

Happy Learning! – Team ShikshaSanchar