Python code to exit program

By IncludeHelp Last updated : February 9, 2024

In Python, to exit a program, you can use the sys.exit() method by passing 0 or any other error code.

Below is the source code to exit a Python program:

Python code to exit program

# Importing sys module
import sys

# Main code
print("Hello, World!")

# Exiting the program

Print("Bye Bye")


Hello, World!

To understand the above code, you should have the basic knowledge of the following Python topics:


Comments and Discussions!

Load comments ↻

Copyright © 2024 All rights reserved.