a=[1,2,3,4]
s=0
for a[-1] in a:
print(a[-1])
s+=a[-1]
print('sum=',s)
The output for the above code is
1
2
3
3
sum= 9
Could you explain why? A dry run would be appreciated.
I tried to come up with a dry run but I did not understand the output at all.