0

Explanation for below code?

arr=[(5,8,0),(2,4)] sum=[] for x, *y in arr: sum += y print(sum)

5th May 2019, 3:21 AM
Shivam Tewari
Shivam Tewari - avatar
1 Antwort
+ 2
for x, *y in arr: print(x, y) Output: 5 [8, 0] 2 [4] Variable "y" takes all the left-over values from each tuple in "arr". Take a look at the second slide of this lesson to get a better understanding. https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2485/
5th May 2019, 4:06 AM
Diego
Diego - avatar