Python provides try-except blocks for handling errors gracefully.
try:\n result = 10 / 0\nexcept ZeroDivisionError:\n print("Cannot divide by zero!")
try:\n num = int("abc")\nexcept ValueError:\n print("Invalid input!")