In [1]:
# While loop
count = 0
while count < 5:
print("Count:", count)
count += 1
Count: 0 Count: 1 Count: 2 Count: 3 Count: 4
In [2]:
# Using break to exit the loop
count = 0
while True:
print("Count:", count)
count += 1
if count == 5:
break
Count: 0 Count: 1 Count: 2 Count: 3 Count: 4