Created
December 26, 2024 11:53
-
-
Save kena2018/ce0700e54e1e15563d697ac70d77ff1b to your computer and use it in GitHub Desktop.
Multiple except blocks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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