9 Collections and Iteration

Looping through an array is one of the most elementary algorithms in programming. Often, it’s one of the first things a new developer does after “Hello, world!” The very principle of starting indices at zero was probably the first paradigm shift you encountered while learning to code. Yet, this is Python; loops and containers here operate on a whole different level.

In this chapter, I’ll cover Python loops and then explore the various collections Python offers for storing and organizing data. Next, I’ll define the concepts of iterables and iterators and start putting them to work in the context of loops. Then, ...

Get Dead Simple 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.