bugl
bugl
HomeLearnPatternsSearch
HomeLearnPatternsSearch

Loading lesson path

Learn/Python/Foundations Practice
Python•Foundations Practice

Python - Change Dictionary Items

Concept visual

Python - Change Dictionary Items

keys map to buckets01kiwi:12pear:43apple:7grape:9

Change Values

You can change the value of a specific item by referring to its key name:

Example

Change the "year" to 2018:

thisdict =  {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict["year"] = 2018

Update Dictionary

The update()

method will update the dictionary with the items from the given argument. The argument must be a dictionary, or an iterable object with key:value pairs.

Example

Update the "year" of the car by using the update() method:

thisdict =  {
"brand": "Ford",
"model": "Mustang",
"year": 1964
}
thisdict.update({"year": 2020})

Previous

Python - Access Dictionary Items

Next

Python - Add Dictionary Items