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:50
Which of the following had the greatest influence on opening the internet to the generly public
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
Acase study allows a more detailed look at the life of a single subject than any other study.
Answers: 3
question
Computers and Technology, 24.06.2019 01:00
What are two ways to access the options for scaling and page orientation? click the home tab, then click alignment, or click the file tab. click the file tab, then click print, or click the page layout tab. click the page layout tab, or click the review tab. click the review tab, or click the home tab?
Answers: 2
question
Computers and Technology, 24.06.2019 04:30
1. web and mobile applications allow users to be actively engaged in an online activity. a true b false 2. some examples of business applications purposes are to collaborate, share files, meet virtually in real-time, and accept payments. a true b false 3. an education application would most likely do which of the following? a allow users to watch popular movies and tv shows b connect users with social and business contacts c confirm users' travel plans d teach users a new language 4. a uniform resource locator (url) is how the internet knows where to take users when an address is typed into a browser. a true b false 5. deon is required to provide the citation information for his sources. what type of information should he collect from his sources? a author name, title, date of publication, date of access, url b connections to background information c interesting facts and statistics d notes on important information
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
Mathematics, 30.10.2020 19:50
question
Mathematics, 30.10.2020 19:50
question
Mathematics, 30.10.2020 19:50
question
Mathematics, 30.10.2020 19:50
question
Chemistry, 30.10.2020 19:50
Questions on the website: 13722360