CHAPTER 11
Working with Lists and Dictionaries
Python provides lists and dictionaries for storing data efficiently in variables. A list is a collection that can store multiple items of the same type or of different types and provides access to its items via an index. A dictionary is similar to a list but more powerful, allowing you to create collections of information that you access through named elements called keys.

Understanding Lists and Their Use
Locate Items and Access Data in a List
Understanding Dictionaries and Their Use
Create a Dictionary and Return Values
Meet Python’s Dictionary Methods
Create a Dictionary from an Existing Iterable
Add Key/Value Pairs to a Dictionary
Understanding Lists and Their Use
In Python, a list is an object that enables you to store multiple items within a single variable. The items can be of the same type or of different types. The list contains an index that enables you to set or retrieve the individual items. Technically, a list is a mutable sequence, so you can change the order of its items, add and remove items, sort the items, and so on.
A List Is Ordered and Indexed
In Python, a list is an ordered and indexed collection:
- Ordered. The items ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access