Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement function lookup() that implements a phone book lookup application. You

ID: 3547692 • Letter: I

Question

                        Implement function lookup() that implements a phone book lookup application. Your functiontakes, as input, a dictionary representing a phone book. Int the                         dictionary, tuples containing first and last names of individual (the keys) are mapped to strings containing phone numbers(the values)                     

                        
                    

                        Your function should provide a simple interface through which a user can enter the first and last names of an individual and obtain the phone number                         asiigned to that individual.                     

                        You must take into consideration that more than one person can have the same first and last name. A modified dictionary that maps a tuple to a list of                         phone numbers could be used to implement a more realistic phone book.                     

Explanation / Answer

You just need to do this with the dictionary


for key, val in telephone_directory.items():

if search_key in key:

print("Found a match! {}".format(val))

break

else:

print("Nothing found")

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote