The break Statement in Loops in Python


Immediately exit a loop, skipping the remaining iterations.

Source Code

for i in range(10):
    if i == 5:
        break  # Exit the loop when i is 5
    print(i)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments