Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Questions: Q4. Dictionary Challenge Write a function called add_dictionary . Given two dictionaries and a key, the function add_dictionary returns a new dictionary, that

Python Questions:

Q4. Dictionary Challenge

Write a function called add_dictionary .

Given two dictionaries and a key, the function add_dictionary returns a new dictionary, that is like dict1 , but has a key-value pair added. The added key is given as a parameter, and the value of that new key is the entire 2nd dictionary, dict2 .

person1 = {'name': 'Homer Simpson', 'role': 'schlub'}

person2 = {'name': 'Mr. Burns', 'role': 'supervisor'}

result = add_dictionary(person1, 'manager', person2)

print(result)

# {'name': 'Homer Simpson', 'role': 'schlub', 'manager': {'name': 'Mr. Burns', rol

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

Students also viewed these Databases questions

Question

In an Excel Pivot Table, how is a Fact/Measure Column repeated?

Answered: 1 week ago