+ 1
How to exit a program in Python?
I want to exit the program if a condition is false. How can I do that?
4 Answers
+ 3
while not condition:
There, if the condition was true before the loop and it becomes false, the loop will break
You could also do
while True:
if condition == False: break
+ 2
You can also make the program in a function, and use a return statement to break out.
+ 1
from sys import exit
if CRAP!!:
exit()