Skip to Main Content
Python Essentials For Dummies
book

Python Essentials For Dummies

by John C. Shovic, Alan Simpson
April 2024
Beginner content levelBeginner
192 pages
3h 46m
English
For Dummies
Audiobook available
Content preview from Python Essentials For Dummies

Chapter 7

Speeding Along with Lists and Tuples

IN THIS CHAPTER

Bullet Defining lists

Bullet Working with lists

Bullet Understanding tuples

Bullet Checking out sets

Sometimes in code you work with one item of data at a time, such as a person’s name or a unit price or a username. Other times, you work with larger sets of data, such as a list of people’s names or a list of products and their prices. These sets of data are often referred to as lists or arrays in most programming languages.

Python has lots of easy, fast, and efficient ways to deal with all kinds of data collections, as you discover in this chapter. As always, we encourage you to follow along in a .py file. The “doing” part helps with the “understanding” part.

Defining and Using Lists

The simplest data collection in Python is a list. We provided examples of these in the preceding chapter. A list is any list of data items, separated by commas, inside square brackets. Typically, you assign a name to the list using an = character, just as you would with variables. If the list contains numbers, don’t use quotation marks around them. For example, here ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python Essentials For Dummies

Python Essentials For Dummies

John C. Shovic, PhD, Alan Simpson
Introduction to Python

Introduction to Python

Jessica McKellar
Python for Data Science For Dummies, 3rd Edition

Python for Data Science For Dummies, 3rd Edition

John Paul Mueller, Luca Massaron
Python for Excel

Python for Excel

Felix Zumstein

Publisher Resources

ISBN: 9781394263479Purchase Link