Chapter 30 One-Dimensional Lists and Dictionaries
30.1 Introduction
Variables are a good way to store values in memory but they have one limitation—they can hold only one value at a time. There are many cases, however, where a program needs to keep a large amount of data in memory, and variables are not the best choice.
For example, consider the following exercise:
Write a Python program that lets the user enter three numbers. It then displays them sorted in ascending order.
Consider the following code fragment. It lets the user enter the three numbers.
When the loop finally finishes iterating, the variable number contains only that last number that was provided. Unfortunately, all the previous two ...
Get Python and Algorithmic Thinking for the Complete Beginner 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.