How can I write a program in Python Dictionary that prints repeated keys values? -


this input:

dic1 = {'a':'usa', 'b':'canada', 'c':'france'} dic2 = {'c':'italy', 'd':'norway', 'e':'denmark'} dic3 = {'e':'finland', 'f':'japan', 'g':'germany’}

i want output below:

{'g': 'germany', 'e': [‘denmark’,’finland'], 'd': 'norway', 'c': ['italy’,'france', 'f': 'japan', 'b': 'canada', 'a': 'usa'}

that programing - think steps need desired results, , write code perform these steps, 1 @ time.

a funciton can it:

def merge_dicts(*args):     merged = {}     dct in args:        key, value in dct.items():            if key not in merged:                merged[key] = []            merged[key].append(value)     return merged 

Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -