t483.py 246 B

1234567891011121314
  1. def divide(x, y):
  2. try:
  3. result = x / y
  4. except ZeroDivisionError:
  5. print "division by zero!"
  6. else:
  7. print "result is", result
  8. divide(2, 1)
  9. divide(2, 0)
  10. try:
  11. divide("2", "1")
  12. except TypeError as e:
  13. print e