![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 13.07.2021 15:20 maggie123456751
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'], 'Fred': ['Agarwal']}
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.
{'Smith': ['Alice', 'Bob'], 'Chan': ['Alice'], 'Agarwal': ['Fred']}
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))
7
![ansver](/tpl/images/cats/User.png)
Answers: 3
![](/tpl/images/ask_question.png)
![](/tpl/images/ask_question_mob.png)
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 21.06.2019 21:00
It is not a good idea in a cover letter to mention another person whom the employer knows.
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 13:30
Use the keyword strategy to remember the meaning of the following word. the meaning for the word has been provided. write your keyword and describe the picture you would create in your mind. centurion: a commander in the army of ancient rome. keyword: picture:
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 05:20
Which operating system is a version of linux?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 23.06.2019 23:30
Perform an online search about the booting process of a computer and list all the steps
Answers: 2
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](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/fizika.png)
![question](/tpl/images/cats/en.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.01.2020 07:31
![question](/tpl/images/cats/en.png)
English, 24.01.2020 07:31
![question](/tpl/images/cats/mat.png)
Mathematics, 24.01.2020 07:31
![question](/tpl/images/cats/health.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.01.2020 07:31
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/biologiya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.01.2020 07:31
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/himiya.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.01.2020 07:31
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
Mathematics, 24.01.2020 07:31
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/biologiya.png)
Biology, 24.01.2020 07:31