# File: chr.py # Program to convert an internal representation to a character # # Matt Bishop, ECS 10, Spring 2014 # # keep going until there is no more input while True: # here we read a number # but end the loop on an EOF (^D on most systems) try: innum = int(input("Enter (non-negative) integer: ")) except EOFError: break except: print("You need to enter a non-negative integer") else: # check that the number is non-negative if innum < 0: print("You need to enter a non-negative integer") else: # print the ordinal values for each character print(innum, "-->", chr(innum)) # that's all, folks! print("Bye!")