Data Structures

Data structures are important for most any serious (and some not so serious) programs. They allow us to store groups of related data under a single variable name and access them quickly and logically. There are many types of data structures available under Python and each will be explained in the following sections.

Data Structure Example

Let’s say that we need to keep a list of color names that are available to the end user and that list has the following values:

Red, Orange, Yellow, Green, Blue, Purple

We could simply create a number of distinct and separate variables to hold each value. On the other hand, we could ...

Get The Python Quick Syntax Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.