Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Heres a Python function that meets your requirements python def upda... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions