Unpack a Coordinate
Beginner · Write the code · from Python Unpacking: Starred Expressions, Swapping, and Destructuring
From the lesson: Python Unpacking: Starred Expressions, Swapping, and Destructuring
Imagine you order a package online that contains three items: a book, headphones, and a phone case. When the box arrives, you open it and put each item where it belongs. The book goes on the shelf, headphones go on the desk, and the case goes on your phone.
Read the lessonUnpack the tuple point into three variables: x, y, and z. Then print them on one line separated by spaces using print(x, y, z).
point = (7, 14, 21)
# Unpack into x, y, z and print them
More Unpacking exercises
- Swap Two VariablesBeginner
- Head and Tail with StarIntermediate
- Predict the Unpacking OutputIntermediate
- Unpack Student RecordsAdvanced
All Python exercises · 50 practice problems · Data Structures quiz