Loop Control: break, continue in Python


Exit a loop or skip to the next iteration.

Source Code

for i in range(10):
    if i == 5:
        break  # Exit the loop
    if i % 2 == 0:
        continue  # Skip even numbers
    print(i)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments