13.1. Introduction

You have previously seen tuples, a sequence type that works just like lists except that they are immutable.

When working with multiple values or multiple variable names, the Python interpreter does some automatic packing and unpacking to and from tuples, which allows some simplifications in the code you write.

13.1.1. Learning Objectives

At the end of this chapter, you will be able to:

  • Recognize when code is using implicit tuple packing

  • Use implicit tuple packing to return multiple values from a function

  • Read and write code that unpacks a tuple into multiple variables

  • Learn a common pattern that unpacks the results of calling enumerate on a sequence

You have attempted of activities on this page
Next Section - 13.2. Tuple Packing