Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Packing | Packing and Unpacking
Intermediate Python: Arguments, Scopes and Decorators
course content

Course Content

Intermediate Python: Arguments, Scopes and Decorators

Intermediate Python: Arguments, Scopes and Decorators

1. Packing and Unpacking
2. Arguments in Function
3. Function as an Argument
4. Variable Scope
5. Decorators

bookPacking

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.

1
*a, *b = 1, 2, 3, 4
copy
1
*a, *b, *c = 1, 2, 3
copy
Can you use more than one iterable unpacking operator in a single expression?

Can you use more than one iterable unpacking operator in a single expression?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 2
some-alt