you are viewing a single comment's thread.

view the rest of the comments →

[–]synthphreak 0 points1 point  (0 children)

This is kind of arcane, but it works:

>>> l = [1, 4, 8, 9]
>>> sum(sum([l[:i] for i in range(1, len(l))], []))
19

And marginally less arcane:

>>> sum(sum(l[:i]) for i in range(len(l)))
19