You can do it like this, by combining slicing and a list comprehension, but it is ungainly to do a cumulative sum efficiently.
comp=[1,4,9,16]
[sum(comp[:idx+1]) for idx in range(len(comp))]
I would not recommend using this, it recalculates the sum n times!
A proper way to cumsum can be done like this:
def cumsum(seq):
cumulative = [seq[0]]
for elt in seq[1:]:
cumulative.append(cumulative[-1] + elt)
return cumulative
itertools.accumulate is another way that @NielsWerner demonstrated.
Further efficiency can be found with the numpy library, and the cumsum function of this library.