Let us consider two dictionaries a and b and let c be the merged dictionary of a and b:
For Python 3.5 or greater:
c = {**a, **b}
Ex-
a={‘x’:1, ‘y’:3}
b={‘y’:2, ‘z’:4}
>>>c
{‘x’:1,’y’:3,’z’:4}
Or, you can also merge in with literal notations:
c={**a, 'cat': 1, 'dog': 2, **b}
For Python 3.4 or lower:
def merge(a,b):
c = a.copy()
c.update(b)
return c
Then,
c=merge(a,b)
Here, merge() is a user defined function.