Question
Define a function reverseDict() that takes one parameter: - fansClub, a dictionary of key: value pairs, where the key is the name of a soccer
Define a function reverseDict() that takes one parameter: - fansClub, a dictionary of key: value pairs, where the key is the name of a soccer fan and the value associated with that key is the list of soccer teams he/she is a fan off. The function returns a dictionary of key:value pairs, where the key is a soccer team and the value is the list of all names of its fans.
For example, fans = {'js':['Real Madrid','Juventus','Spain'], 'john': ['Real Madrid','France'], 'Alissa':['Roma','France']}
print(reverseDict(fans))
Output:
{'Real Madrid': ['js','john'], 'Juventus':['js'], 'Spain':['js'], 'France':['john','Alissa'], 'Roma': ['Alissa']}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started