Home

9: Error Handling

Errors in Python

You can find a list of built-in exceptions on the docs.

Example of error handling:

try: print(5/0) except ZeroDivisionError: print("You can't divide by zero!") except NameError as err: print(f"You can't divide by zero! {err}") # To group them together except (TypeError, ValueError) as err: print(f"You can't divide by zero! {err}") else: print('Thank you!') finally: print('This is always printed')

Repository

https://github.com/okeeffed/developer-notes-nextjs/content/python/Learn-To-Code-With-Python-Course/9-Error-Handling

Sections


Related