# Program to read in a positive number # and complain when the input isn't that # # Matt Bishop, ECS 10, Fall 2012 # # the program itself # def main(): # # loop to show how to break out of an infinite loop # while True: # read in a positive integer # handle any exceptions (relatively) intelligently try: n = int(input("type a number: ")) # some exception except: print("Exception -- ignoring!") # ignore the problem continue # no exception -- print the number if n <= 0: print("You typed a non-positive number") else: print("Read", n) print("\n-----------------------\n") main()