This is the simplest way to merge or combine two dictionaries in python. This operation in supported in python version above 3.5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| dict_01 = {'p':2, 'q':4} | |
| dict_02 = {'r':6, 's':8} | |
| combined = {**dict_01, **dict_02} | |
| print(combined) |
Sample Output
{'p': 2, 'q': 4, 'r': 6, 's':8}