Let say I have A=[2,4, 3 ,1], I want to compute the sum of element inside by skipping one element in each step.
What I try is:
s=[ ]
a=0
for i in range(len(A)):
for j in range(len(A)):
if i==j:
continue
else :
a +=A[j]
s.append(a)
When I print the result s I am getting
print(s)
s=[8, 14, 21, 30]
What I want to have is:
s=[ 8, 6, 7, 9]
Where
8=4+3+1 we skip
A[0]
6=2+3+1 we skipA[1]
7=2+4+1 we skipA[2]
9=2+4+3 we skipA[3]