Chapter 7. Data Structures

In this chapter, we introduce the important idea of data structures: collections of values along with commonly performed functions. Python’s programmer-friendly philosophy is to provide a few powerful and efficient data structures—tuples, lists, dictionaries, and sets—that can be combined as needed to make more complex ones.

In the previous chapter we discussed strings, which can be thought of as data structures restricted to storing sequences of characters. The data structures in this chapter can contain not just characters but almost any kind of data.

Python’s two workhorse data structures are lists and dictionaries. Lists are simple, flexible data structures with many uses. Dictionaries, while necessarily a little more ...

Get Python: Visual QuickStart Guide, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.