Python Forum

Full Version: while true loop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
how do I break out of a While True loop in python3
Take a break.
I faced similar issue as you (not knowing which google result out of so many to open)

https://wiki.python.org/moin/WhileLoop
Break example in second code snippet
It is worth noting that a non-null entry evaluates to True, so it is common to have a loop that prompts a user to enter something or just return to exit:
while True:
    answer = input("Enter a phrase (enter alone to exit): ")
    if not answer:
        break
    print(f'You entered {answer}.')
print('All done.')