# File: divby0.py # See what happens when you divide by 0 # # Note: to get to the last two parts (where this catches the exception), # comment out the first division # # Matt Bishop, ECS 10, Winter 2012 # # # this can be any integer # -- if you want to see the ifference between the two catches, # set this to a string like 'hello' x = 100 # # Divide, and bomb #y = x / 0 # # Here's how you check for it try: y = x / 0 except: print("Error occurred") # # And here you catch *only* the division by zero try: y = x / 0 except ZeroDivisionError: print("You can't divide by 0!")