The Python update method is useful for updating key-value pairs of a dictionary. It is instrumental in updating one dictionary value with another or inserting key-value pairs from user inputs. In this section, we discuss how to use the Dictionary update function, and the syntax is:
dictionary_name.update(others)
This Dictionary update Example method updates the dictionary object with another one.
TIP: Refer to the Dictionary in this language.
myDict = {1: 'apple', 2: 'Banana'}
myNewDict = {3: 'Orange', 4: 'Kiwi'}
print("Items: ", myDict)
print("New Items: ", myNewDict)
myDict.update(myNewDict)
print("\nItems : ", myDict)
