given a dictionary of characters with their favorite foods. sort the characters and their favorite foods. return a dictionary where the keys are characters and the values are the friends who like the same foods. if more than one character likes the same food sort alphabetically. >>> friends1 = {"Famy": ["pizza", "chocolate"], "Nihal": ["chocolate","hotdog"], "Amy":["chocolate", "chips"]} >>> friendsfoods(friends1) {'pizza': ['Famy'], 'chocolate': ['Amy', 'Famy', 'Nihal'], 'hotdog': ['Nihal'], 'chips': ['Amy']} >>> friends2 = {'Alissa': ['pizza', 'hotdog'], 'Arun': ['pizza', 'chips'], 'Michele': ['icecream', 'burger', 'fries']} >>> friendsfoods(friends2) {'pizza': ['Alissa', 'Arun'], 'hotdog': ['Alissa'], 'chips': ['Arun'], 'icecream': ['Michele'], 'burger': ['Michele'], 'fries': ['Michele']} Subject: Python Programming
given a dictionary of characters with their favorite foods. sort the characters and their favorite foods. return a dictionary where the keys are characters and the values are the friends who like the same foods. if more than one character likes the same food sort alphabetically.
>>> friends1 = {"Famy": ["pizza", "chocolate"],
"Nihal": ["chocolate","hotdog"],
"Amy":["chocolate", "chips"]}
>>> friendsfoods(friends1)
{'pizza': ['Famy'], 'chocolate': ['Amy', 'Famy', 'Nihal'], 'hotdog': ['Nihal'], 'chips': ['Amy']}
>>> friends2 = {'Alissa': ['pizza', 'hotdog'],
'Arun': ['pizza', 'chips'],
'Michele': ['icecream', 'burger', 'fries']}
>>> friendsfoods(friends2)
{'pizza': ['Alissa', 'Arun'], 'hotdog': ['Alissa'], 'chips': ['Arun'], 'icecream': ['Michele'], 'burger': ['Michele'], 'fries': ['Michele']}
Subject: Python Programming
Step by step
Solved in 2 steps with 2 images