What does "while True" mean in Python?

What does “while True” mean in Python?

Hello Asheenaraghununan,

here is your Answer to the Question:-

In Python, while True is used to create an infinite loop. The loop will continue to run indefinitely until a break statement is encountered or the program is terminated.

Hello Asheenaraghununan,

This construct is commonly used when the exact number of iterations is not known beforehand or when the loop needs to run until a certain condition is met.

Hello Asheenaraghuhan,

The while True loop continues to ask the user for input until the user enters ‘quit’, at which point the loop is exited.

Example :

while True: user_input = input("Enter ‘quit’ to exit: ") if user_input.lower() == ‘quit’: break print(“Exited the loop”)