Account
Categories

Break Statement


Definition:

When you use this statement in a loop, it stops immediately, and the program moves to the next part after the loop.

Syntax:

break

Example:

for i in range(1, 10):
    if i == 3:
        break
    print(i)

Output:

Exercise

Write a Python program to stop the loop when value becomes 3 using break statement.