Adding dictionaries together, Python

The Solution to Adding dictionaries together, Python is


If you're interested in creating a new dict without using intermediary storage: (this is faster, and in my opinion, cleaner than using dict.items())

dic2 = dict(dic0, **dic1)

Or if you're happy to use one of the existing dicts:

dic0.update(dic1)

~ Answered on 2011-05-14 22:33:38


Most Viewed Questions: