Exiting a Python Application
There exist several ways of exiting Python script applications, and the following article provides detailed explanations of several such approaches How to exit Python script.
Exit using Python Exit() Method
In this example, we will see How to Use the exit()
Function in Python. The “exit()” statement terminates the program immediately, preventing the execution of any subsequent code. Therefore, the “print(“this is the second statement”)” line is never reached.
Python3
print ( "this is the first statement" ) exit() print ( "this is the second statement" ) |
Output:
this is the first statement
How to Exit a Python script?
In this article, we are going to see How to Exit Python Script.
Exiting a Python script refers to the termination of an active Python process. In this article, we will take a look at exiting a Python program, performing a task before exiting the program, and exiting the program while displaying a custom (error) message.
Contact Us