Define a function named update_contact (list_of_tuples, search_name, new_phone) that takes a list of tuples, a name...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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. 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.
Expert Answer:
Answer rating: 100% (QA)
Heres a Python function that meets your requirements python def upda... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
You are required to write a Python program that will manage character (heroes and villain) information. Character (hero and villain) information will be stored in a text file that will be read in...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Debate on Causes of Unemployment Two economists are debating the cause of a high unemployment rate. One economist argues that there is not enough government spending. The other says high unemployment...
-
Dry air will break down and generate a spark if the electric field exceeds about 3 X 106N/C. How much charge could be packed onto a green pea (diameter 0.75cm) before the pea spontaneously discharges?
-
1. When fed free-choice, a cow will usually eat 2 Ib. of good quality hay per 100 lb. of body weight. Using this rule of thumb, how much hay per day would a 1,350-lb. cow car? If alfalfa hay sells...
-
Refer to the statements for Google in Appendix A. For the year ended December 31, 2015, what was its debt-to-equity ratio? What does this ratio tell us? Data From Statement Google In Appendix A...
-
Alabama Corporation purchases raw materials on account from various suppliers. It normally pays for 70 percent of these in the month purchased, 20 percent in the first month after purchase, and the...
-
A car traveling 87.0 km/h is 1500 m behind a truck traveling at 74.0 km/h. How far from its initial position does the car have to travel to catch up to the truck.
-
The sector rotates with the indicated angular quantities about a fixed axis through point B. Simultaneously, the particle A moves in the curved slot with constant speed u relative to the sector....
-
The 2017 balance sheet of Dream, Inc., showed current assets of $4,530 and current liabilities of $2,830. The 2018 balance sheet showed current assets of $3,200 and current liabilities of $1,650....
-
Co. plans to pay the following dividends: $10, $15, $7, $3. Afterwards, dividends are expected to grow at a constant rate of 5%. Required return is 13%. What is the current share price?
-
Block A can slide relative to block B, which can slide on a perfectly smooth horizontal plane as shown. If block A is given an initial velocity vo, find the distance that A slide RELATIVE to B....
-
New Town Bank offers you a line of credit of $50,000 with an interest rate of 2.1 percent per quarter. The loan agreement also requires that 2.5 percent of the unused portion of the credit line be...
-
If two coils placed next to one another have a mutual inductance of 5.00 mH, what voltage is induced in one when the 2.00 A current in the other is switched off in 30.0 ms?
-
Roxanne is a human resources director Tech Touch, a global tech company that employs over 5,000 employees across Canada. Roxanne meets with Jeannie, a group insurance agent because she wants to...
-
Exfoliation and sheeting occurs because water combines with minerals and increases their size, thereby causing surrounding minerals to expand. water freezes in joints and expands. overlying rock is...
-
Use this circle graph to answer following Exercises. 1. What fraction of areas maintained by the National Park Service are designated as National Recreation Areas? 2. What fraction of areas...
-
Patty Bayan is a single taxpayer living at 543 Space Drive, Houston, TX 77099. Her Social Security number is 466-33-1234. For 2012, Patty has no dependents, and her W-2 from her job at a local...
-
Frank Willingham has the following transactions during the year: Sale of office equipment on March 15 that cost $20,000 when purchased on July 1, 2010. Frank has claimed $5,000 in depreciation and...
-
Ann hires a nanny to watch her two children while she works at a local hospital. She pays the 19-year-old nanny $125 per week for 48 weeks during the current year. a. What is the employer's portion...
-
True or False: When dealing with multiple alternatives having unequal lives, the planning horizon equals the least common multiple of lives.
-
For each of the following categories, describe some of the difficulties that you would face in estimating appropriate values to be used in conducting an economic analysis. a. Cash flows b. MARR c....
-
Given the following information about sources of capital, what is the appropriate weighted average cost of capital to use in determining MARR? a. 9.87 percent b. 10.55 percent c. 12.42 percent d....
Study smarter with the SolutionInn App