Introduction

This week will be devoted to working with Collections and Loops.

A collection is just, well, that, a collection of elements ¯_(ツ)/¯_. Up to this point we've worked with single/individual objects: an integer, a string, etc. A collection will let you store many of those single elements under the same "container" (the collection). Let's say you're working for Spotify and you're in charge of implementing the functionality to display music albums. An album is just a "collection" of songs. Your individual object is a Song and your collection is the album.

Working with collections requires a good understanding of looping constructs. That is, for and while loops. The bad news is that it's impossible to "isolate" these topics. To understand collections properly, it's key to understand looping, but to loop, you need to understand collections.

Recommended readings

Start with Chapter 4 about Lists from Automate the Boring Stuff. It's a good introduction to lists and basic looping. For more details about loops, you can use the chapter about Control Flow from A Byte of Python. Specially the parts about while and for loops.