Python Dictionary update() Method
Example
Insert an item to the dictionary:
car = {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
car.update({"color": "White"})
print(car)
Try it Yourself »
Definition and Usage
The update()
method inserts the specified
items to the dictionary.
The specified items can be a dictionary, or an iterable object with key value pairs.
Syntax
dictionary.update(iterable)
Parameter Values
Parameter | Description |
---|---|
iterable | A dictionary or an iterable object with key value pairs, that will be inserted to the dictionary |
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.