Question: in python Function name: trip. planner Parameters: list of tuples Returns: dictionary with each value as a dictionary Description: You and your friends are planning

in python in python Function name: trip. planner Parameters: list of tuples Returns: dictionary

Function name: trip. planner Parameters: list of tuples Returns: dictionary with each value as a dictionary Description: You and your friends are planning a trip to NYC! In preparation, you guys make a list together of things you want to do when you get to NYC, except it's a little bit disorganized with a lot of duplicate activities. Your job is to organize the list into a more accessible dictionary Each element in the input list is a tuple containing the category (string), name (string), and cost (int) of the activity. The output dictionary should arrange the activities first by using their category a s keys. The assigned value of each category should be another dictionary that maps each corresponding activity name to its associated cost. If there are duplicate activities with the same category and name, their costs should all be added together. >>> list1 = [('show', 'Shawn Mendes: the Concert, 100), ('food', 'Levan Bakery, 10000), (sightseeing', 'Statue of Liberty', 0), ('show', 'Hamilton', 20), (sightseeing', Brooklyn Bridge', 10), ('show, 'Hamilton', 70), (food', Halal Guys', 5), (show, 'Shawn Mendes: the Concert', 200)] >>> print(trip planner(list1)) fshow': f'Shawn Mendes: the Concert: 300, Hamilton': 90), food': [Levain Bakery' 10000, Halal Guys': 5), 'sightseeing: f'Statue of Liberty': 0, 'Brooklyn Bridge': 10))

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!