Skip to main content

Python Break Statement

Python Break Statement terminates the current loop and resumes execution at the next statement, just like the traditional break statement in C.

If you need to exit a loop early, then you can use the break keyword. This keyword will work in both for and while loops. The most common use for break is when some external condition is triggered requiring a hasty exit from a loop.

Example:

for letter in 'ProgramBuzz':    
    if letter == 'g':
        break
    print ('Current Letter :', letter)

Output: 

Current Letter : P
Current Letter : r
Current Letter : o

Tags
Submitted by devanshi.srivastava on June 3, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.