Question: Please create in python no import allowed create a function called combine_dict that will take in two dictionaries as input and return a new dictionary

Please create in python no import allowed

create a function called combine_dict that will take in two dictionaries as input and return a new dictionary with all the key:value pairs from the two dictionaries. If a dictionary shares a key then the value from the second dictionary will be appended to the list from the first dictionary. Here is an example what the function should do:

>>> d1 = {'r': [1, 4, 3], 'b': [5], 'c': [ 6, 9]} >>> d2 = {'r': [2], 'b': [8, 10, 0], 'd': [10, 11, 12]} >>> combine_dict(d1, d2) {'r': [1, 4, 3, 2], 'b': [5, 8, 10, 0], 'c': [ 6, 9], 'd': [10, 11, 12]} 
>>> combine_dict(d2,d1) 
{'r': [2,1, 4, 3], 'b': [ 8, 10, 0,5], 'c': [ 6, 9], 'd': [10, 11, 12]} 

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!