Python Dictionary update() Method
Example
Insert Items into Dictionary:
car = { "brand": "Porsche", "model": "911", "year": 1963 } car.update({"color": "White"}) print(car)
Definition and Usage
The update() method inserts the specified items into the dictionary.
This specified item can be a dictionary or an iterable object.
Syntax
dictionary.update(iterable)
Parameter Value
Parameter | Description |
---|---|
iterable | Dictionaries or iterable objects with key-value pairs will be inserted into the dictionary. |