Editor

Unpack a Tuple

Beginner · Write the code · from Python Tuples: When and Why to Use Immutable Sequences

From the lesson: Python Tuples: When and Why to Use Immutable Sequences

Think about GPS coordinates. A location like (40.7128, -74.0060) represents New York City. If you accidentally changed one of those numbers, the location would point somewhere completely different. Some data simply should not change after you create it.

Read the lesson

A tuple representing a student record is given. Unpack it into three variables: name, age, and grade.

Then print each variable on its own line.

Expected output:

Emma
16
A
student = ('Emma', 16, 'A')
# Unpack the tuple into name, age, grade
# Print each variable

More Tuples exercises

All Python exercises · 50 practice problems · Data Structures quiz