O'Reilly logo

The Quick Python Book by Naomi R. Ceder

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Lists, tuples, and sets

This chapter covers

  • Manipulating lists and list indices
  • Modifying lists
  • Sorting
  • Using common list operations
  • Handling nested lists and deep copies
  • Using tuples
  • Creating and using sets

In this chapter, we’ll discuss the two major Python sequence types: lists and tuples. At first, lists may remind you of arrays in many other languages, but don’t be fooled—lists are a good deal more flexible and powerful than plain arrays. This chapter also discusses a newer Python collection type: sets. Sets are useful when an object’s membership in the collection, as opposed to its position, is important.

Tuples are like lists that can’t be modified—you can think of them as a restricted type of list or as a basic record type. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required