How to merge two Python dictionaries (union)

Date Created
Programming Languages
Python
>>> x = {'a':1, 'b': 2}
>>> y = {'b':10, 'c': 11}
>>> z = x.copy()
>>> z.update(y)
{'a': 1, 'c': 11, 'b': 10}
>>> a = {'q':1, 'b': 3}
>>> b = {'b':2, 'x': r}
>>> c = x.copy()
>>> d.update(y)
{'y': 1, 'q': 11, 'x': 10}