devxlogo

Merge Two Dictionaries in Python

Merge Two Dictionaries in Python

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}
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist