Skip to content

Computer Science · Ch 10 — Tuples and Dictionaries

Dictionaries are Mutable

10.8

Dictionaries are Mutable

In sharp contrast to tuples, dictionaries are mutable — the contents of a dictionary can be changed after it has been created. Nothing needs to be rebuilt or reassigned wholesale; the dictionary object itself is updated in place.

The two everyday ways of changing a dictionary are covered in the sub-sections that follow:

  • 10.8.1 Adding a new item — assigning a value to a brand-new key inserts a fresh key-value pair. …