subject

Create a function(Python) called `addressbook` that takes as input two dictionaries, `name_to_phone` and `name_to_address`, and combines them into a single dictionary `address_to_all` that contains the phone number of, and the names of all the people who live at, a given address. Specifically, your function should: 1. Have input arguments `addressbook(name_to_phone, name_to_address)`, expecting `name_to_phone` as a dictionary mapping a name (string) to a home phone number (integer or string), and `name_to_address` as a dictionary mapping a name to an address (string).
2. Create a new dictionary `address_to_all` where the keys are all the addresses contained in `name_to_address`, and the value `address_to_all[address]` for `address` is of the format `([name1,name2,...], phone)`, with `[name1,name2,...]` being the list of names living at `address` and `phone` being the home phone number for `address`. **Note**: the *value* we want in this new dictionary is a *tuple*, where the first element of the tuple is a *list* of names, and the second element of the tuple is the phone number. (Remember that while a tuple itself is immutable, a list within a tuple can be changed dynamically.)
3. Handle the case where multiple people at the same address have different listed home phone numbers as follows: Keep the first number found, and print warning messages with the names of each person whose number was discarded.
4. Return `address_to_all`.
For example, typing in
name_to_phone = {'alice': 5678982231, 'bob': '111-234-5678', 'christine': 5556412237, 'daniel': '959-201-3198', 'edward': 5678982231}
name_to_address = {'alice': '11 hillview ave', 'bob': '25 arbor way', 'christine': '11 hillview ave', 'daniel': '180 ways court', 'edward': '11 hillview ave'}
address_to_all = addressbook(name_to_phone, name_to_address)
print(address_to_all)
```
should return
```
Warning: christine has a different number for 11 hillview ave than alice. Using the number for alice.
{'11 hillview ave': (['alice', 'christine', 'edward'], 5678982231), '25 arbor way': (['bob'], '111-234-5678'), '180 ways court': (['daniel'], '959-201-3198')}
```Your message should match exactly as shown above. If more than one person has a different phone number at the same address then use a `,` to separate the names.
Note that the specific order you get these elements back may not be the same, because sets and dictionaries do not preserve order. That is OK!

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 15:00, vdkgknsdg9996
Much has been made of the new web 2.0 phenomenon, including social networking sites and user-created mash-ups. how does web 2.0 change security for the internet? how do secure software development concepts support protecting applications?
Answers: 1
image
Computers and Technology, 22.06.2019 21:00, daniella0123
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings starting from index 0. for each match, add one point to userscore. upon a mismatch, exit the loop using a break statement. assume simonpattern and userpattern are always the same length. ex: the following patterns yield a userscore of 4: simonpattern: rrgbryybgy userpattern: rrgbbrybgy
Answers: 2
image
Computers and Technology, 23.06.2019 09:30, rscvsdfsrysas3712
Why is an outfitting a workspace with video games in a technology development company considered a strategic use of money
Answers: 1
image
Computers and Technology, 23.06.2019 18:00, bubbles173883
While inserting images, the picture command is usually used to insert photos from a digital camera, and the clip art command is usually used to a. edit the sizes and other characteristics of photos that have been inserted. b. take a screenshot of an image and copy it to the clipboard for pasting. c. search for drawings or other images from a library of prepared pictures. d. make illustrations using lines and shapes that are easy to manipulate.
Answers: 1
You know the right answer?
Create a function(Python) called `addressbook` that takes as input two dictionaries, `name_to_phone`...

Questions in other subjects: