0
values match
I tried this example: a, b, *rest = [1,2,3,4] Without the squared brackets and still got in the interpreter an output with squared brackets. Can anyone help me differ?
3 Respuestas
+ 1
You can’t store multiple values into a single variable that is not a list, dictionary, set ect. So you can do
a, b, c, d = [1, 2, 3, 4]
or
a, b, *rest = [1, 2, 3, 4]
c, d = rest
0
a and b take 1 and 2 respectively. *rest will always be a list so Python doesn’t have to check how many values are leftover.
0
Is it a matter of putting everything in parentheses?