bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Python/Foundations
Python•Foundations

Python - Add Dictionary Items

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Python - Add Dictionary Items?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___ = {
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The argument must be a dictionary, or an iterable object with key:value pairs.
The update() method will update the dictionary with the items from a given argument.
Adding an item to the dictionary is done by using a new index key and assigning a value to it:

Adding Items

Adding an item to the dictionary is done by using a new index key and assigning a value to it:

Example

thisdict =  {

"brand": "Ford",

"model": "Mustang",

"year": 1964

}
thisdict["color"] = "red"
print(thisdict)

Update Dictionary

The update() method will update the dictionary with the items from a given argument. If the item does not exist, the item will be added.

The argument must be a dictionary, or an iterable object with key:value pairs.

update()

Previous

Python - Change Dictionary Items

Next

Python - Remove Dictionary Items