4 Dealing with sequence data

This chapter covers

  • Using slice objects to retrieve and manipulate subsequences
  • Combining the use of positive and negative indexing in item retrieval
  • Finding items in a sequence
  • Unpacking a sequence
  • Considering data models other than lists

In chapter 3, you learned to use lists and tuples to hold data. One shared characteristic of lists and tuples is that the held items have a specific order. These two data structures are examples of the more general data type sequence. Python has other sequence data types, such as strings and bytes. These sequence data models are essential data structures that we use in our projects. The reason is simple: we use data to model real life, which is full of ordered objects/events, ...

Get Python How-To 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.