What Does It Mean Program Exited With Code 0 in Python?

For every Python program, when we execute the code, Python will return the code to understand the status of the program execution once the execution is complete. The program will be terminated once all the lines in the program are executed. “program exited with code 0” means the code is successfully executed and the program has no errors.

What are the Three Python Status Codes?

  • exit(0) – The program has no errors and the operation completed successfully
  • exit(1) – There are some issues in your code
  • exit(-1) – User interruped the flow of the execution. In this case, Python interpreter doesn’t know anything about the execution results as the operation was aborted in the middle of run.

What is Program Exited With Code 1 in Python?

If you have any errors in your code, the program will terminate the execution and return status code 1 along with the information about the issues. Below, is the example.

Example

Output

What is Program Exited With Code 0 in Python?

If there are no errors in the code, the program will run successfully and return the output with status code 0. If the status code is 0, you needn’t debug your code.

Example

Output

What is Program Exited With Code -1 in Python?

This is a very rare scenario that happens only when you use code editors such as PyCharm. If you use the command-line interface to run a code, you won’t see such errors. This code indicated that the program is terminated abnormally either by the user or by any other external or internal factors.

Example 1

Output

Example 2

Output

I stopped the program by using the stop button in the PyCharm editor and so the interpreter returned the status code -1.