Home >>Python Dictionary Methods >Python Dictionary update() Method
Python Dictionary update() Method is used to add the specified items to the dictionary with the elements from the another dictionary object.
Syntax:dictionary.update(iterable)
Parameter | Description |
---|---|
iterable | A dictionary or an iterable object with a list of key value pairs |
det = {
"name": "rohan",
"lname": "singh",
"year": 1990
}
det.update({"color": "blue"})
print(det)
incolor = {'blue': 250, 'yellow':190, 'red':1980,'pink':150}
print("Inventory:",incolor)
incolor.update({'white':550})
print("Updated color:",incolor)
incolor.update({'white':350})
print("Updated color:",incolor)