generate list of partially accumulated values

buffi bjorn.kempen at gmail.com
Sun Sep 16 06:06:23 EDT 2007


Uh... that turned out weird.

Anyways, here goes again

l = [1, 2, 3, 4]
[sum(l[:x+1]) for x in xrange(len(l))]




More information about the Python-list mailing list