# A program that implements a rudimentary phone catalog: # - First asks the user to specify the number of entries in the catalog. # - Second asks the user to enter enter names and phone numbers. # - Third, enters in a loop where the user enters a name and the # program looks up and prints out the corresponding phone number. # get number of entries N = input("enter number of entries: ") # initialize lists that will store names and phone numbers # convention: the programmer will make sure that numbers[i] stores # the phone number for names[i]. names = [] numbers = [] # get from the user the names and phone numbers. for i in range(0, N): name = raw_input("enter a name: ") number = raw_input("enter a phone number for " + name + ": ") names.append(name) numbers.append(number) # now, get in a loop where the user enters a name, and the computer # looks up and prints out the corresponding phone number. while True: name = raw_input("enter a name to look up: ") for i in range(0, N): if name == names[i]: print "the phone number of", name, "is", numbers[i] name_found = True # note: the above while loop never terminates, the user # must press to quit this program.