0
I don’t understand how to interpret this ? And why answer is 3?
Def function (a, *b ) : Print (list(b)[1]) Function (5,4,3,2,1)
3 Respuestas
+ 9
The issue is not tuple unpacking here but function arguments. You can find more in this short tutorial:
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/4409/?ref=app
+ 5
a=5,b = [4,3,2,1],b[1]=3
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2485/
+ 2
*b means *args in other words all not mentioned arguments of function is collected as list named args (this is convention, in your case b instead of args) so,
a = 5
b = [4,3,2,1]
and function just prints 1st elem of list. i.e
b[0]=4
b[1]=3
b[2]=2
b[3]=1