What is unpacking and how can you use it?

Python lists, dictionaries and sets · Freshers and experienced

Model answer

Assigning items to several variables: a, b = (1, 2). Starred unpacking collects the rest: first, *rest = items. It also swaps values (a, b = b, a) and unpacks function arguments with * and **.

Learn this topic

Dictionaries, Tuples and Sets in Python in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions