Skip to main content
- Last updated
Save as PDF
- 9.1: Dictionaries
- A dictionary is like a list, but more general. In a list, the index positions have to be integers; in a dictionary, the indices can be (almost) any type. You can think of a dictionary as a mapping between a set of indices (which are called keys) and a set of values. Each key maps to a value. The association of a key and a value is called a key-value pair or sometimes an item.
- 9.2: Dictionary as a Set of Counters
- An implementation is a way of performing a computation; some implementations are better than others. For example, an advantage of the dictionary implementation is that we don't have to know ahead of time which letters appear in the string and we only have to make room for the letters that do appear.
- 9.3: Dictionaries and Files
- One of the common uses of a dictionary is to count the occurrence of words in a file with some written text.
- 9.4: Looping and Dictionaries
- If you use a dictionary as the sequence in a for statement, it traverses the keys of the dictionary.
- 9.5: Advanced Text Parsing
- 9.6: Debugging
- 9.E: Dictionaries (Exercises)
- 9.G: Dictionaries (Glossary)