subject

Make a backwards phonebook from a regular phonebook

your function should take 2 parameters: infile and outfile

infile should be a phonebook in the same format as question 2 (version 2).

outfile should be a list of phone number people pairs, sorted by phone number

as with question 2, you should account for the possibility that 2 people may share a single phone number (e. g., a land line if they live in the same home)

first read in all phone numbers into a dictionary, the same as you had done for question 2. you can call functions defined in question 2 and use global variables from question 2 as well if it makes sense to do so.

read through that dictionary and create a backwards version.

in the new dictionary the keys are phone numbers and the values are lists of people

use a similar strategy as with version 2 of question 2:

if a number is not in the dictionary, you create a new entry which is a list of a single person

otherwise, you check the list associated with that number and you add a person's name if they are not already listed in the (backwards) phonebook

create a list of keys from the dictionary and sort it.

for each key in the list, look up the corresponding entry/

for each name in the entry (also a list), write a line in the output firle consisting of a telephone number + a tab + a name

for example, given the sample file

name phone number
bob 212-888-
bugs 917-433-
daffy 914-400-4141
daffy 800-999-
daisy 914-400-4141
daisy 123-456-7890
pippi 301-999-9990
pippi 800-333-4400
yosemite 212-333-
as input, the program would produce

telephone number name
123-456-7890 daisy
212-333- yosemite
212-888- bob
301-999-9990 pippi
800-333-4400 pippi
800-999- daffy
914-400-4141 daisy
914-400-4141 daffy
917-433- bugs
as output (notice that daffy and daisy share a phone number).

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 18:30
Which of the following commands is more recommended while creating a bot?
Answers: 1
question
Computers and Technology, 22.06.2019 18:30
Which of these options are the correct sequence of actions for content to be copied and pasted? select content, click the copy button, click the paste button, and move the insertion point to where the content needs to be inserted. click the copy button, select the content, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, click the copy button, move the insertion point to where the content needs to be inserted, and click the paste button. select the content, move the insertion point to where the content needs to be inserted, click the copy button, and click the paste button.
Answers: 3
question
Computers and Technology, 22.06.2019 20:00
When you mouse over and click to add a search term this(these) boolean operator(s) is(are) not implied. (select all that apply)?
Answers: 1
question
Computers and Technology, 23.06.2019 16:30
You have read about the beginnings of the internet and how it was created. what was the internet originally created to do? (select all that apply) share research. play games. communicate. share documents. sell toys
Answers: 1
You know the right answer?
Make a backwards phonebook from a regular phonebook

your function should take 2 paramete...
Questions
question
Social Studies, 30.07.2019 03:00
Questions on the website: 13722367