Chapter 13

Managing Lists

IN THIS CHAPTER

check Defining why lists are important

check Generating lists

check Managing lists

check Using the Counter object to your advantage

A lot of people lose sight of the fact that most programming techniques are based on the real world. Part of the reason is that programmers often use terms that other people don’t to describe these real-world objects. For example, most people would call a place to store something a box or a cupboard — but programmers insist on using the term variable. Lists are different. Everyone makes lists and uses them in various ways to perform an abundance of tasks. In fact, you’re probably surrounded by lists of various sorts where you’re sitting right now as you read this book. So, this chapter is about something you already use quite a lot. The only difference is that you need to think of lists in the same way Python does.

You may read that lists are hard to work with. The reason that some people find working with lists difficult is that they’re not used to actually thinking about the lists they create. When you create a list, you simply write ...

Get Beginning Programming with Python For Dummies, 2nd Edition 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.