MyInternships.in

Python Control Flow

Python Break Continue and Pass

break, continue and pass give you fine control over how loops behave: stopping them early, skipping an iteration, or doing nothing as a placeholder.


The break Statement

break immediately exits the loop it is inside, skipping any remaining iterations entirely. Execution jumps straight to the first line of code after the loop.

break example
Python
for num in range(1, 10):
    if num == 5:
        break
    print(num)
Output
Output
1
2
3
4

The continue Statement

continue skips the rest of the current iteration and jumps straight to the next one — the loop keeps running, it just moves on early for that particular pass.

continue example
Python
for num in range(1, 6):
    if num % 2 == 0:
        continue
    print(num)
Output
Output
1
3
5

The pass Statement

pass does nothing at all. It is a placeholder used when Python’s syntax requires a statement (like inside an if, loop, or function) but you have not written the real logic yet.

pass example
Python
for num in range(5):
    if num == 3:
        pass  # TODO: handle this case later
    print(num)

When to Use Each One

StatementEffectTypical use case
breakExits the loop completelyStop searching once a match is found
continueSkips to the next iterationSkip invalid or unwanted items
passDoes nothing, acts as a placeholderStub out code you will write later
⚠️

pass does not stop or skip anything — it is easy to confuse with continue at first, but pass simply lets execution flow through as if that line were not there.

💡

Use pass while sketching out empty functions or classes, like def my_function(): pass, so your code stays syntactically valid while you plan the details.

Related Python Topics

Keep learning with these closely related lessons.

Ready to use your Python skills?

Find Python, data science and software internships and fresher jobs across India.

Browse Python Internships