3.2.2 Tuple Unpacking
Tuple unpacking allows multiple variables to be assigned at once from a tuple.
This makes code cleaner and more expressive.
How Tuple Unpacking Works
- Each element in the tuple is assigned to a corresponding variable
- The number of variables must match the number of elements
- Assignment occurs in order
Common Use Cases
- Assigning multiple return values from a function
- Swapping variable values
- Iterating over paired data
📌 Note:
Tuple unpacking is widely used in Python and improves code readability.