# Chapter8.py page 235 # application passes all steps -> Exit Code 0 # application fails a step -> Exit Code 1 aka 'crashes' # HANDLE exception errors with a try/except block try: # This will try to execute each line individually print("Welcome to my application") # try pass/fails-> except #filename = input("What file do you want to open: ") with open('myContacts.txt') as file: # try content = file.read() print(content) x = 0 y = 0 z = x / y print(z) except FileNotFoundError as err: print(err) print("do something here to handle this specific error.") except ZeroDivisionError as err: print(err) print("do something here to handle this specific error.") except MemoryError as err: print(err) print("do something here to handle this specific error.") except Exception as err: print(err) # finally (optional) finally: print("Code here that always runs no matter if the code passes or fails.")