How to Stop Loop Even If While Condition Is True in Python


In this example, we will learn how to stop the loop even if the while condition is true in Python.

Source Code

a = 3
while a > 0:
    print(a)
    if a == 15:
        break
    a += 4

Output:

3
7
11
15
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments