Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions