Skip to content

Instantly share code, notes, and snippets.

@kena2018
Created December 26, 2024 11:53
Show Gist options
  • Save kena2018/ce0700e54e1e15563d697ac70d77ff1b to your computer and use it in GitHub Desktop.
Save kena2018/ce0700e54e1e15563d697ac70d77ff1b to your computer and use it in GitHub Desktop.
Multiple except blocks
try:
num = int(input("Enter a number: "))
result = 10 / num
except ZeroDivisionError:
print("Cannot divide by zero.")
except ValueError:
print("Invalid input. Please enter a valid integer.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment