Python break statement

The loop executes the statement inside the body without skipping any line of the code. As a developer, you may require to terminate the loop upon fulfilment of some condition.

The Python break statement is used to move the execution control outside the loop. Whenever the control reaches a break statement, the executed loop gets terminated, and the control points to the next line of code immediately after the loop.

For example


for num in range(45, 60):
   if num == 53:



45 46 47 48 49 50 52 53

As you can see in the above code snippet, when the if condition becomes True, the control reaches a break statement which stops the execution of loop.