Question: Language: Python Topic: Dictionaries Function name: get_restaurants Parameters: a dictionary containing restaurants as keys and their values being a list of the items that they

Language: Python

Topic: Dictionaries

Function name: get_restaurants Parameters: a dictionary containing restaurants as keys and their values being a list of the items that they serve Returns: a dictionary containing the items as keys and their values being a list

Description: Now that youre in New York City, you are trying to find the locations that serve specific food items, but you only have the restaurant names and their menus. Write a function called get_restaurants that takes in a dictionary with the restaurant names as keys and a list of the items they sell. You should return a dictionary containing the items as keys and their values being a list of the restaurants that serve that item.

>>> iceCreamPlaces = {"Mister Dips": ["ice cream"], "Morgenstern's Finest": ["ice cream"], "The Original Chinatown Ice Cream": ["ice cream"]} >>> iceCream = get_restaurants(iceCreamPlaces) >>> print(iceCream)

{'ice cream': ['Mister Dips', "Morgenstern's Finest", 'The Original Chinatown Ice Cream']}

>>> chineseRestaurants = {"Red Farm" : ["dumplings", "hot and sour soup"], "Kung Fu Little Steamed Buns": ["dumplings", "noodles"], "Hunan Slurp" : ["noodles", "dumplings"], "Xi'an Famous Foods": ["noodles"]} >>> chineseFoods = get_restaurants(chineseRestaurants)

>>> print(chineseFoods) {'dumplings': ['Red Farm', 'Kung Fu Little Steamed Buns', 'Hunan Slurp'], 'hot and sour soup': ['Red Farm'], 'noodles': ['Kung Fu Little Steamed Buns', 'Hunan Slurp', "Xi'an Famous Foods"]}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!