dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Tip: Merge Two Dictionaries in Python

Learn more about how to use the Dictionary Class in Python to merge two dictionaries.


advertisement

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


The Dictionary class in Python provide an update() function that allows you to merge two dictionaries.

For example:

employeeScore = { 'Emp1':100, 'Emp2':98, 'Emp3':96}
employee2019Score= { 'Emp1':101, 'Emp2':104}

To merge, just use:

employeeScore.update(employee2019Score)

The contents of the employeeScore dictionary would be:

employeeScore = { 'Emp1':101, 'Emp2':104, 'Emp3':96}

 

Visit the DevX Tip Bank

 





   
Srinath M. S. says: "I would love to leave a footprint in this flat world."
Thanks for your registration, follow us on our social networks to keep up-to-date