python how to exit the program code example Example 1: python exit program import sys sys.exit() Example 2: python how to exit function return None