What’s the difference between exit(0) and exit(1) in Python?
I tried looking around but didn’t find a specific question on these lines. If it’s already been answered, a link would be sufficient.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
0 and 1 are the exit codes.
exit(0)means a clean exit without any errors / problemsexit(1)means there was some issue / error / problem and that is why the program is exiting.This is not Python specific and is pretty common. A non-zero exit code is treated as an abnormal exit, and at times, the error code indicates what the problem was. A zero error code means a successful exit.
This is useful for other programs, shell, caller etc. to know what happened with your program and proceed accordingly.