Last active
August 25, 2017 14:00
-
-
Save jpralves/f2c63097e9b6fa4517bbc02e7e4dee38 to your computer and use it in GitHub Desktop.
Using python exceptions in a strange way
This file contains 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
from random import randint | |
print("Number ", end="") | |
i = randint(0, 9) | |
print(i, "is ", end="") | |
try: | |
j = 1/(i % 2) + 'a' | |
except TypeError: | |
print("odd") | |
except ZeroDivisionError: | |
print('even') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment