0
Explain in detail ?
list = [1,2,3,4] a,*b,c = list print(list) print(a) print(b) print(c)
2 Respuestas
+ 2
The key here is in the line
a, *b, c = list
Here, a takes the first element (1), c takes the last element (4), and, because b has the little * before it, it takes everything else that lies in between, so it is [2, 3] in this case. See some other examples here.
lst = [1,2,3,4]
a,b,*c = lst # a = 1, b = 2, c = [3,4]
*a,b,c = lst # a = [1,2], b = 3, c = 4
a,b,c,d = lst # a = 1, b = 2, c = 3, d = 4
a, *b = lst # a = 1, b = [2,3,4]
Hope this helps.
0
Russ Thanks sir ...