# File: except0.py # Program to read in a positive number # and complain when the input isn't that # # Matt Bishop, ECS 36A, Winter 2019 # # loop to show exception handling # while True: # read in a positive integer # handle any exceptions (relatively) intelligently try: n = int(input("type a number: ")) # some exception except: print("Exception -- quitting!") # boom -- end the program break # no exception -- print the number if n <= 0: print("You typed a non-positive number") else: print("Read", n) print("\n-----------------------\n")