© Irv Kalb 2016

Irv Kalb, Learn to Program with Python, 10.1007/978-1-4842-2172-3_11

11. Data Structures

Irv Kalb

(1)Mountain View, California, USA

Let’s start this chapter with the following definition.

Definition

A data structure is a collection of multiple pieces of data, arranged in a way that the data can be accessed efficiently.

The only data structure that we have discussed so far is a list. A list allows us to refer to any one of multiple pieces of data using an index. Python has a few more built-in data structures, which is the topic of this chapter.

We will cover the following topics:

  • Tuple

  • Lists of lists

  • Representing a grid or a spreadsheet

  • Representing the world of an adventure game

  • Reading a comma-separated value (.csv) file

  • Dictionary

  • Using ...

Get Learn to Program with Python 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.