AI engineering glossary · Python core
What is tuple unpacking?
Tuple unpacking (also called sequence unpacking): Assigning the items of a sequence to several names in one statement, matched by position. The number of names must match the number of items unless a starred name is used. It is also used to swap values without a temporary variable.
Tuple unpacking: an example
x, y = (3, 4) sets x to 3 and y to 4. a, b = b, a swaps two variables.
Related terms
More Python core terms
Where you learn it
Tuple unpacking is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.