I have a following code with different outputs
def func1(*args):
print(type(args))
print('Func1')
for k in args:
print (k)
def func2(args):
print(type(args))
print('Func2')
for k in args:
print (k)
func1([1,2,3])
func2([1,2,3])
while I generally know what unpacking operator does, I’m not sure why prints are so different.
The output is the following:
<class 'tuple'>
Func1
[1, 2, 3]
<class 'list'>
Func2
1
2
3
So, if in func1 arguments are unpacked and put into a tuple, I would expect that each print call put end of line, instead it behaves exactly as list is printed with square brackets.