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, 21.06.2019 21:30
Ajeweler designing a pin has decided to use five stones chosen from diamonds, rubies, and emeralds. in how many ways can the stones be selected?
Answers: 3
question
Computers and Technology, 23.06.2019 18:00
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
question
Computers and Technology, 24.06.2019 15:30
How do i change the size of my bookmarks in my bookmarks bar in google chrome? ? plz hlp me
Answers: 2
question
Computers and Technology, 25.06.2019 08:50
A-12.3 an american spy is deep undercover in the hostile country of phonemia. in order not to waste scarce resources, any time he wants to send a message back home, he removes all the punctuation from his message and converts all the letters to uppercase. so, for example, to send the message, “abort the plan! meet at the dark cabin.” he would transmit given such a string, s, of n uppercase letters, describe an efficient way of breaking it into a sequence of valid english words. you may assume that you have a function, valid(s), which can take a character string, s, and return true if and only if s is a valid english word. what is the running time of your algorithm, assuming each call to the function, valid, runs in o(1) time?
Answers: 3
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