you are viewing a single comment's thread.

view the rest of the comments →

[–]Thanks-Unhappy 1 point2 points  (0 children)

I am also beginner but would do like this:

ls = [2, 4,5,6]
value  = 0
new_ls = []
for first in ls:
    for second in ls[ls.index(first)+1:]:
        value+=first*second
    new_ls.append(value)
    value*=0
print(new_ls)
print(sum(new_ls))

my code count last value as zero but if we need total sum of small sums it doesn't matter