Course Content
Intermediate Python Techniques
Intermediate Python Techniques
Packing
To pack multiple variables, you need to use the *
iterable unpacking operator. Simply place an asterisk *
before the variable, and it will pack any number of variables. Packing a variable is only possible within a tuple or a list.
But the SyntaxError will occur if to use more than one unpacking operator.
*a, *b = 1, 2, 3, 4
*a, *b, *c = 1, 2, 3
Thanks for your feedback!