{"id":877,"date":"2014-09-24T10:17:25","date_gmt":"2014-09-24T10:17:25","guid":{"rendered":"https:\/\/fir3netwp.gmsrrpobkbd.com\/2014\/09\/24\/python-how-do-i-merge-2-dictionaries\/"},"modified":"2021-07-24T17:07:19","modified_gmt":"2021-07-24T17:07:19","slug":"python-how-do-i-merge-2-dictionaries","status":"publish","type":"post","link":"https:\/\/www.fir3net.com\/Programming\/Python\/python-how-do-i-merge-2-dictionaries.html","title":{"rendered":"Python – How do I merge 2 dictionaries ?"},"content":{"rendered":"
Below shows you how to merge 2 dictionaries. It is also worth noting that any items will be overwritten by the 2nd dictionary should they exist in both. This is also shown below via the bananas items.<\/p>\n
>>> x = {'apples': 1, 'bananas': 2}
>>> y = {'bananas':3 , 'coconuts': 4}
>>> dict(x.items() + y.items())
{'coconuts': 4, 'apples': 1, 'bananas': 3}
>>><\/pre>\n","protected":false},"excerpt":{"rendered":"Below shows you how to merge 2 dictionaries. It is also worth noting that any items will be overwritten by the 2nd dictionary should they exist in both. This is also shown below via the bananas items. >>> x = {‘apples’: 1, ‘bananas’: 2}>>> y = {‘bananas’:3 , ‘coconuts’: 4}>>> dict(x.items() + y.items()){‘coconuts’: 4, ‘apples’: … Read more<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"yoast_head":"\n
Python - How do I merge 2 dictionaries ? - Fir3net<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n