Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago

Question

What does the start( ) method defined by Thread do?

Answered: 1 week ago