Skip to main content

Unpacking operator in code and function header

Unpacking

In Python you are allowed to do deconstruction similar to how you can do deconstruction assignment in JavaScript. You can take a list and then assign each of the elements individually to variables on the left hand. For example:

(a, b, c) = (1, 2, 3)
# a = 1
# b = 2
# c = 3

If you are