Python has this feature built-in:

>>> d = {'b': 4}
>>> d.update({'a': 2})
>>> d
{'a': 2, 'b': 4}

Or given you're not allowed to use dict.update:

>>> d = dict(d.items() + {'a': 2}.items())   # doesn't work in python 3
Answer from Eric on Stack Overflow
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-dictionary-update-method
Python Dictionary update() method - GeeksforGeeks
3 weeks ago - Explanation: update({'a': 50}) replaces old value of 'a'. Example 3: In this example, keyword arguments are used instead of another dictionary.
Discussions

Here's a quick way to update a dictionary with a second dictionary: use the '|=' operator.
This is cool and nice to know about, but frankly DictA.update(DictB) is better IMHO. The result is exactly the same, but itโ€™s more readable / less opaque and arcane. Even Pythonistas who have never heard of dict.update can probably guess what it does, unlike |= which you already have to be in-the-know about. dict.update is probably more backwards compatible too, though Iโ€™m less certain about this. More on reddit.com
๐ŸŒ r/learnpython
12
54
May 27, 2023
Python Dictionary update - is this right approach?
Firstly, you don't need to do template_data.update(sddspecs). The sddspecs variable you have is a reference to the one inside template_data, so any changes will be reflected there directly. However, you could use update to do the actual changes, without having to specify each one individually: sddcspecs = template_data.get("sddcManagerSpec") updates = { "hostname": "test", "ipAddress", "someip", "netmask": "somedata", ...etc... } sddcspecs.update(updates) print(template_data) More on reddit.com
๐ŸŒ r/learnpython
8
1
July 3, 2024
The Performance Impact of Using dict() Instead of {} in CPython 2.7
as a general principle I try to avoid code constructions I know to introduce performance hits. As a general principle I try to put readability before microoptimization. We're talking about 239 nanoseconds here. Most of the time a dictionary with fixed keys looks better as dict(), and requires less typing to boot. More on reddit.com
๐ŸŒ r/Python
124
141
May 31, 2012
Equivalent of dictionary.update() but for appending when value is a collection?
There is not an exact equivalent, but there are things that are similar. I would suggest using a default dict: import collections d = collections.defaultdict(list) d[5].append(4) But if it had to be a standard dictionary, you could do d[ind] = d.get(ind, []) + [x] Note: the second will not modify existing lists in place, which may or may not be a problem. EDIT: Per u/commy2 's reply below, setdefault is better way if you're restricted to regular dictionaries - especially if your lists will be getting long so that copying them is nontrivial, or if it's important to modify the lists in place. More on reddit.com
๐ŸŒ r/learnpython
4
2
July 20, 2024
๐ŸŒ
Programiz
programiz.com โ€บ python-programming โ€บ methods โ€บ dictionary โ€บ update
Python Dictionary update()
The update() method updates the dictionary with the elements from another dictionary object or from an iterable of key/value pairs.
๐ŸŒ
DigitalOcean
digitalocean.com โ€บ community โ€บ tutorials โ€บ python-add-to-dictionary
How to Add and Update Python Dictionaries Easily | DigitalOcean
October 16, 2025 - The update() method overwrites the values of existing keys with the new values. The following example demonstrates how to create a new dictionary, use the update() method to add a new key-value pair and a new dictionary, and print each result:
Find elsewhere
๐ŸŒ
Oreate AI
oreateai.com โ€บ blog โ€บ using-the-python-dictionary-update-method โ€บ 0c2a1bcf87689d70361351213c5e7967
Using the Python Dictionary Update Method - Oreate AI Blog
December 22, 2025 - Syntax of the update method The syntax for the update method is as follows: dict.update(dict2) Here, 'dict' is the dictionary to be updated and 'dict2' can be another dictionary or an iterable sequence of key-value pairs to add to 'dict'.
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_dictionaries_change.asp
Python - Change Dictionary Items
The update() method will update the dictionary with the items from the given argument.
๐ŸŒ
Tutorialspoint
tutorialspoint.com โ€บ home โ€บ python โ€บ python dictionary update
Python Dictionary Update
February 21, 2009 - Then another dictionary 'dict2' is created which consist of the key 'Sex' and its corresponding value 'female'. Thereafter, using the update() method 'dict' gets updated with the items provided in 'dict2'.
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ tutorial โ€บ datastructures.html
5. Data Structures โ€” Python 3.14.3 documentation
This chapter describes some things youโ€™ve learned about already in more detail, and adds some new things as well. More on Lists: The list data type has some more methods. Here are all of the method...
๐ŸŒ
Python
peps.python.org โ€บ pep-0584
PEP 584 โ€“ Add Union Operators To dict | peps.python.org
This PEP proposes adding merge (|) and update (|=) operators to the built-in dict class.
๐ŸŒ
Python
docs.python.org โ€บ 3 โ€บ library โ€บ collections.html
collections โ€” Container datatypes
A ChainMap incorporates the underlying mappings by reference. So, if one of the underlying mappings gets updated, those changes will be reflected in ChainMap. All of the usual dictionary methods are supported.
๐ŸŒ
Codecademy
codecademy.com โ€บ docs โ€บ python โ€บ dictionaries โ€บ .update()
Python | Dictionaries | .update() | Codecademy
May 13, 2025 - Updates the dictionary with key-value pairs from another dictionary or iterable, overwriting existing keys if they exist.
๐ŸŒ
KDnuggets
kdnuggets.com โ€บ 2023 โ€บ 02 โ€บ update-python-dictionary.html
How to Update a Python Dictionary - KDnuggets
February 20, 2023 - Learn how to update a Python dictionary using the built-in dictionary method update(). Update an existing Python dictionary with key-value pairs from another Python dictionary or iterable.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ python-update-dictionary-with-other-dictionary
Update Dictionary with other Dictionary - Python - GeeksforGeeks
July 12, 2025 - Explanation: a[key] = b[key] for each key in b, its corresponding value in a is updated. If the key exists in a, its value is replaced with the value from b. This method involves manually looping through the second dictionary and checking whether ...
๐ŸŒ
W3Schools
w3schools.com โ€บ python โ€บ python_dictionaries.asp
Python Dictionaries
Python Tuples Access Tuples Update Tuples Unpack Tuples Loop Tuples Join Tuples Tuple Methods Tuple Exercises Code Challenge Python Sets ยท Python Sets Access Set Items Add Set Items Remove Set Items Loop Sets Join Sets Frozenset Set Methods Set Exercises Code Challenge Python Dictionaries
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-update-a-dictionary-in-python
How to Update a Dictionary in Python - GeeksforGeeks
July 23, 2025 - The below approach code updates a dictionary (main_dict) by creating a copy (updated_dict) using the copy() method, and then using the update() method to add new key-value pairs ('c': 3, 'd': 4) to the copied dictionary.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
Add and Update an Item in a Dictionary in Python | note.nkmk.me
August 25, 2023 - Expand and pass a list and dictionary as arguments in Python ยท d1 = {'k1': 1, 'k2': 2} d2 = {'k1': 100, 'k3': 3, 'k4': 4} d3 = {'k5': 5, 'k6': 6} # d1.update(d2, d3) # TypeError: update expected at most 1 arguments, got 2 d1.update(**d2, **d3) print(d1) # {'k1': 100, 'k2': 2, 'k3': 3, 'k4': 4, 'k5': 5, 'k6': 6}