I am trying to understand how *args works as a parameter of a function/method.
>>> l
['1', '2', '3']
>>> def test(*args):
print(type(args))
for arg in args:
print(arg)
>>> test(*l)
<class 'tuple'>
1
2
3
>>> m = *l
SyntaxError: can't use starred expression here
I get SyntaxError when I try to assign *l to a variable but when I pass the same to function test() it works just fine. I want to understand how is this working with function and why do i get SyntaxError when I try to do the same and assign it to a variable instead.