lis =[-2,1,-3,4,-1,2,1,-5,4]
m=[]
for i in range(len(lis)):
if len(lis)>=1:
s = sum(lis)
m.append(s)
print(m)
print(lis)
lis.remove(lis[len(lis)-1])
print(lis)
result :
[1]
[-2, 1, -3, 4, -1, 2, 1, -5, 4]
[-2, 1, -3, -1, 2, 1, -5, 4]
[1, -3]
[-2, 1, -3, -1, 2, 1, -5, 4]
[-2, 1, -3, -1, 2, 1, -5]
[1, -3, -7]
[-2, 1, -3, -1, 2, 1, -5]
[-2, 1, -3, -1, 2, 1]
[1, -3, -7, -2]
[-2,1, -3, -1, 2, 1]
-----[-2, -3, -1, 2, 1]------this is the line that i didn't understand. why it remove the second index not the late index as i wrote in the code.
[1, -3, -7, -2, -3]
[-2, -3, -1, 2, 1]
[-2, -3, -1, 2]
[1, -3, -7, -2, -3, -4]
[-2, -3, -1, 2]
[-2, -3, -1]
[1, -3, -7, -2, -3, -4, -6]
[-2, -3, -1]
[-2, -3]
[1, -3, -7, -2, -3, -4, -6, -5]
[-2, -3]
[-2]
[1, -3, -7, -2, -3, -4, -6, -5, -2]
[-2]
[]