subject

There's a roster of unique names, and we created a dictionary of first name to list of last names. For example, the roster Alice Chan Bob Smith Fred Agarwal Alice Smith We've created this dictionary mapping first name to a list of associated last names, but dumped the original roster unfortunately: {'Alice': ['Chan', 'Smith'], 'Bob': ['Smith'], 'Frei But now, we want to search by last name. So given only the above dictionary, return a new dictionary where the key is last name instead of first name. {'Chan': ['Alice'], 'Smith': ['Alice', 'Bob'], 'Aga A Few Notes: A Few Notes: 1. The order of the lists of first names is ambiguous, but return it sorted alphabetically from A-Z. That means, 'Smith' should map to ['Alice', 'Bob'], NOT ['Bob', 'Alice').
2. Even if there's only one person with that last name, make sure it's mapped to a list. That means, 'Agarwal should map to ['Fred'], NOT 'Fred'
3. Recall dictionaries (and sets) are unordered, so don't be alarmed if the print statement didn't have the last names in the same order as above. BUT, for each last name, the list of first names associated must be sorted.
4. We've assumed the original roster had unique names, so there aren't any issues with that. 1 def reverse_roster (fn_dict:dict) -> dict: 2 # TODO: Your code here (-10-20 lines of code) 3 4 if __name__ == '__main__':
5 sample = {'Alice': ['Smith', 'Chan'], 'Bob': ['Smith'], 'Fred': ['Agarwal']}
6 print (reverse_roster (sample))

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:00
Aisha has finished working on a word processing document that contains 15 pages. she has added some special elements in the first three pages, page 9 and 10, and page 15 from the document. she wants to print only these pages to see how they look. which option is the correct way to represent (in the print dialog box) the pages that aisha wants to print?
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
What allows you to create a wireless connection among your smart devices
Answers: 2
question
Computers and Technology, 22.06.2019 19:00
How is the number 110 written when expanded out to place values in the base 2 (binary) number system? options: 2 x 4 + 3 x 2 + 4 x 1 1 x 2 + 1 x 2 + 0 x 2 1 x 100 + 1 x 10 + 0 x 1 1 x 4 + 1 x 2 + 0 x 1
Answers: 1
question
Computers and Technology, 23.06.2019 20:30
If chris has a car liability insurance, what damage would he be covered for
Answers: 1
You know the right answer?
There's a roster of unique names, and we created a dictionary of first name to list of last names. F...
Questions
question
Physics, 20.07.2019 21:20
Questions on the website: 13722363