Exiting in python is fairly straight-forward. You need to import the "sys" library, and then call exit from it.
1 2 3 |
import sys sys.exit() |
Calling exit with no arguments is a clean exit -- no error code is returned. If you'd like to exit with an error message, simply pass the message as a parameter and exit will automatically exit with an error and print your message.
1 2 3 |
import sys sys.exit("This is an example of an error message") |





