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 Techniques
course content

Conteúdo do Curso

Intermediate Python Techniques

Intermediate Python Techniques

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?

Selecione a resposta correta

Tudo estava claro?

Como podemos melhorá-lo?

Obrigado pelo seu feedback!

Seção 1. Capítulo 2
some-alt