Nikolay Blokhin Facebook Nikolay Blokhin Photos Nikolay Blokhin Linkedin Nikolay Blokhin Twitter

Hi, I'm Nikolay Blokhin I build the cool things with Python and Swift

How to merge two dicts in Python

Not many people know that in recent versions of Python there is a convenient way to merge two dictionaries: {**a, **b}

>>> a = {'key1': 1, 'key2': 2} >>> b = {'key3': 3, 'key4': 4} >>> d = {**x, **y} >>> print(d) {'key1': 1, 'key2': 2, 'key3': 3, 'key4': 4}