Introduction

Published

2023-08-02

Dictionaries are ubiquitous, no doubt due to their usefulness and flexibility. Dictionaries store information in key/value pairs—we look up a value in a dictionary by its key. In this chapter we’ll learn about dictionaries: how to create them, modify them, iterate over them and so on.

Learning objectives

  • You will learn how to create a dictionary.
  • You will understand that dictionaries are mutable, meaning that their contents may change.
  • You will learn how to access individual values in a dictionary by keys.
  • You will learn how to iterate over dictionaries.
  • You will understand that dictionary keys must be hashable.

Terms and Python keywords introduced

  • del
  • dictionary
  • hashable
  • key
  • value
  • view object

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

This material is for free use under either the GNU Free Documentation License or the Creative Commons Attribution-ShareAlike 3.0 United States License (take your pick).