


PYTHON INTERMEDIATE
Exceptions
Use try and except blocks to handle exceptions. This prevents your program from crashing when a runtime error occurs.
How it reads
try: wraps the code that might fail at runtime
except ValueError: catches and handles specific ValueErrors

Cloud tip: Always catch specific errors (like ValueError or KeyError) instead of a generic Exception.
