Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Aprenda Packing in Python: Grouping Multiple Values into a Single Variable | Mastering Packing and Unpacking in Python
Intermediate Python Techniques
course content

Conteúdo do Curso

Intermediate Python Techniques

Intermediate Python Techniques

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

book
Packing in Python: Grouping Multiple Values into a Single Variable

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
question mark

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
We're sorry to hear that something went wrong. What happened?
some-alt