I have a problem understanding the process of argument unpacking from a list using the star operator in python.
I have followed the documentation entry and tried to re-create my own little example.
So I've defined a simple list of numbers:
list = [1, 2, 3]
and made a quick check, this works:
print(1, 2, 3)
(1, 2, 3)
and this (just for heads-up):
print([1, 2, 3])
[1, 2, 3]
On the other hand this bit fails:
print(*[1, 2, 3])
File "<stdin>", line 1
print(*[1, 2, 3])
^
SyntaxError: invalid syntax
And this also fails:
print(*list)
File "<stdin>", line 1
print(*list)
^
SyntaxError: invalid syntax
I made sure everything in the documentation works:
list = [1, 2]
range(*list)
[1]
And it did.
I'd like to understand how exactly argument unpacking from list works and what to expect from it, because it doesn't seem as straightforward as I thought.