Introduction

Published

2023-07-31

In this chapter, we’ll introduce two new types, lists and tuples. These are fundamental data structures that can be used to store, retrieve, and, in some contexts, manipulate data. We sometimes refer to these as “sequences” since they carry with them the concepts of order and sequence.

Strings (str) are also sequences.

Learning objectives

  • You will learn about lists, and about common list operations, including adding and removing elements, finding the number of elements in a list, checking to see if a list contains a certain value, etc.
  • You will learn that lists are mutable. This means that you can modify a list after it’s created. We can append items, remove items, change the values of individual items and more.
  • You will learn about tuples. Tuples are unlike lists in that they are immutable—they cannot be changed.
  • You will learn that strings are sequences.
  • You will learn how to use indices to retrieve individual values from these structures.

In the next chapter, we’ll learn how to iterate over the elements of a sequence.

Terms introduced

  • list
  • tuple
  • mutable
  • immutable
  • index
  • sequence unpacking
  • slicing

Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >

No generative AI was used in producing this material. This was written the old-fashioned way.

This material is for free use under either the GNU Free Documentation License or the Creative Commons Attribution-ShareAlike 3.0 United States License (take your pick).