Chapter 6Secret Codes

Image

Now that you have mastered if statements, there is only one major topic left to learn. And so in this chapter we’re going to start to explore loops.

Lists

Loops are super important. Different types of loops, and how to properly use them, is the focus of the next few chapters.

But, before we look at loops, let’s take a few moments to revisit a special type of variable, the list. We briefly showed you lists already. Back in Chapter 3 you used this code:

choices=["Heads","Tails"]

As we explained then, variables usually store a single value. Lists are a special type of variable that can store lots of values (as well as 0 ...

Get Captain Code: Unleash Your Coding Superpower 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.