9HITTING THINGS WITH LISTS AND DICTIONARIES

image

We use lists, such as shopping lists or lists of instructions, to remember a group of items or to work through steps in a certain order. Lists in Python are very similar: they’re used to store a collection of data within a sequence. A list can store several types of data, including strings, numbers, Booleans, and even other lists.

Normally, variables can hold only one value. Lists are useful because they allow you to store several values in a single variable, such as the numbers from 1 to 100 or your friends’ first names. In other programming languages, lists are sometimes called arrays.

You can use ...

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