Question: Define a function named update_contact (list_of_tuples, search_name, new_phone) that takes a list of tuples, a name and a phone number as parameters. The function

Define a function named update_contact (list_of_tuples, search_name, new_phone) that takes a list of tuples,

Define a function named update_contact (list_of_tuples, search_name, new_phone) that takes a list of tuples, a name and a phone number as parameters. The function updates an existing contact tuple in the list if the name exists in the list by removing the existing tuple and adding a new tuple to the end of the list using the parameter name and phone number. The function should also print a message to indicate the contact has been changed. Note: if the parameter name does not exist, the function should print "xxx is not found." where xxx is the parameter name. Note: you can assume that the contact list contains unique contacts only. For example: Test data = [('Jill', '5239980'), ('Bob', '4562345'), ('Jenny', '2541273')] update_contact (data, 'Bob', '1111111') update_contact (data, 'Daniel', '2222222') display_all(data) Result Bob's phone number has been updated. Daniel is NOT found. Jill's phone number is 5239980 Jenny's phone number is 2541273 Bob's phone number is 1111111 There are 3 contacts in the list.

Step by Step Solution

3.49 Rating (146 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python function that meets your requirements python def upda... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!