Python Dictionary update

The Python update method is used to update key-value pairs of a dictionary. It is instrumental in updating one dictionary value with other or in inserting key-value pairs from user inputs. In this section, we discuss how to use it and the syntax is:


Python Dictionary update Example

This method updates the dictionary object with another one.

TIP: Refer to the Dictionary in Python.

myDict = {1: 'apple', 2: 'Banana'}
myNewDict = {3: 'Orange', 4: 'Kiwi'}
print("Items: ", myDict)
print("New Items: ", myNewDict)

print("\nItems  :  ",  myDict)
Python Dictionary update Example