0
Why do we need * in (*bar) in the code below?
def foo(a,b,c): print(a,b,c) bar=(3,14,15) foo(*bar)
3 Respuestas
+ 2
its more like:
def foo(*bar):
for b in bar:
print(b, end=' ')
Input:
foo(1,3,5,7)
foo(2,4)
Output:
1 3 5 7
2 4
And for what happens when its not there, try it out and see
+ 1
* allows you to pass an arbitrurary amount of arguments. The variable bar is usually: args (as in arguments)
0
Slick So what happens it it is not used here?