CHAPTER 25   •   PYTHON

Python Break

Learn how to stop a loop early.

01 What is this?

Learn how to stop a loop early.

02 Syntax

Python Syntax
break

03 Example

Python Example
for i in range(1, 10):
    if i == 5:
        break
    print(i)

04 Important Points

Break immediately exits the current loop.

05 Common Mistakes

Use break only when ending the loop is actually required.

06 Real World Use

Break is useful when a required item has been found.

07 Practice This Topic

Now try the example yourself in the AIFA Python Editor.

  • Read the example carefully.
  • Change the values.
  • Run the code.
  • Observe the output.
  • Try creating your own example.
Try It Yourself →