Interview Question

What is tuple unpacking?

Unpacking assigns iterable items to several targets.

💡 Concept ✅ Quick Revision 🐍 Python

Answer

Tuple unpacking is sequence unpacking that assigns items to multiple targets. • The number of items must match unless a starred target collects extras. • Unpacking works with any suitable iterable, not only tuples. • It is useful for swaps and structured return values.

💡 Simple Example

point = (10, 20) x, y = point print(x, y)

Output

10 20

⚡ Quick Revision

Unpacking assigns iterable items to several targets.