Question: Implement function lookup() that implements a phone book lookup application. Your function takes a dictionary representing a phone book as input, mapping tuples (containing the
Implement function lookup() that implements a phone book lookup application. Your function takes a dictionary representing a phone book as input, mapping tuples (containing the first and last name) to strings (containing phone numbers). Your function should repeatedly ask for first name and last name, and print the phone number. If the name doesn't exist in the dictionary, print 'NOT FOUND'. For example, Enter the first name: Anna Enter the last name: Karenina (123)456-78-90 Enter the first name: Anna Enter the last name: Tsun NOT FOUND Enter the first name:
phonebook = { ('Anna','Karenina'):'(123)456-78-90', ('Yu', 'Tsun'):'(901)234-56-78', ('Hans', 'Castorp'):'(321)908-76-54'}
lookup(phonebook)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
