Question: Can someone write this code in python. Please use return(). def merge(d1,d2): Consider two dictionaries d1 and d2 of the same structure: with strings as
def merge(d1,d2): Consider two dictionaries d1 and d2 of the same structure: with strings as keys and a list as values. This function creates a combined dictionary of the same structure but with the merged information from both d1 and d2: o For a key s that belongs to only one of the original dictionaries in a pair like s:xs, include o For a key s that is present in both di and d2, like sxs in di and sys in d2, ?nclude s: zs in o Return value: the newly created dictionary. Do NOT update d1 or d2. the same pair in the new dictionary; the new dictionary where zs is the concatenation of xs and ys. Keep the duplicates in zs. . Examples: o d1- f'cardinal'I'Virginia', 'ohio'1, meadowlark':['Oregan']) o d2#('robin' :('Connecticut')) o d3 'meadowlark' :I 'Wyoming'], 'cardinal' :I'Virginia', 'Illinois', oriole':['Maryland']) o merge(d1,d2) ? ('cardinal'[ 'Virginia', 'ohio'], 'meadowlark' :['Oregan'], 'robin':l'Connecticut'l) o merge(d1,d3) ('cardinal''Virginia', 'Ohio', 'virginia','Illinois'1,'meadowlark':['Oregan, Wyoming'], 'oriole':'Maryland'])
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
