Skip to content

Instantly share code, notes, and snippets.

@jpralves
Last active August 25, 2017 14:00
Show Gist options
  • Save jpralves/f2c63097e9b6fa4517bbc02e7e4dee38 to your computer and use it in GitHub Desktop.
Save jpralves/f2c63097e9b6fa4517bbc02e7e4dee38 to your computer and use it in GitHub Desktop.
Using python exceptions in a strange way
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