What is Python Break Statement?


When a situation outside of the system is triggered, the break statement in Python is used to pull the control out of the loop. Inside the loop, the body is a break statement (generally after if condition).

Syntax:

break

Example:

i = 1

while i < 7:

  print(i)

  if (i == 4):

    break

  i += 1

Output:

1

2

3

4


Leave a Reply

Your email address will not be published. Required fields are marked *