Python Program to Using the break statement in a while loop

In the following example of Python program that demonstrates how to use the `break` statement in a `while` loop :
Program :
# Using the break statement in a while loop
count = 0

while True:
    print("Count is", count)
    count += 1
    if count == 5:
        break

print("Done.")
Output :
Count is 0
Count is 1
Count is 2
Count is 3
Count is 4
Done.
In this program, we use a `while` loop with a `True` condition to repeat a block of code indefinitely. Inside the loop, we print the current value of `count` using the `print()` function and increment the value of `count` by `1` using the `+=` operator.

We also use an `if` statement to check if the value of `count` is equal to `5`. If it is, we use the `break` statement to exit the loop.

When the `break` statement is executed, the program continues to execute the `print()` statement outside the loop, which prints the message "Done."

You can use the `break` statement to exit a loop prematurely if a certain condition is met.