partial sums problem

kj no.email at please.post
Tue Sep 28 18:57:08 EDT 2010



The following attempt to get a list of partial sums fails:

>>> s = 0
>>> [((s += t) and s) for t in range(1, 10)]
  File "<stdin>", line 1
    [((s += t) and s) for t in range(1, 10)]
          ^
SyntaxError: invalid syntax

What's the best way to get a list of partial sums?

TIA!

kj



More information about the Python-list mailing list