Python Fundamentals ยท Control Flow
Repeat while a condition stays true. Watch the condition being checked before every round, and the loop stop once it turns false.
savings = 100
months = 0
while savings < 150:
savings = savings + 20
months = months + 1
print("reached", savings, "after", months, "months")months is created with the value 0.savings < 150 to decide whether the loop keeps going.savings changes from 120 to 140.months changes from 1 to 2.months changes from 2 to 3.