Да, используйте встроенный itertools.accumulate
:
>>> from itertools import accumulate
>>> limit = 10
>>> list(accumulate(range(1, limit+1)))
[1, 3, 6, 10, 15, 21, 28, 36, 45, 55]
Примечание. itertools.accumulate
может принимать любые двоичные операции, но по умолчанию используется сложение,
>>> list(accumulate(range(1, limit+1))) # defaults to addition
[1, 3, 6, 10, 15, 21, 28, 36, 45, 55]
>>> list(accumulate(range(1, limit+1), lambda x,y : x + y)) # you could pass it as an argument
[1, 3, 6, 10, 15, 21, 28, 36, 45, 55]
but you could use multiplication as an example:
>>> list(accumulate(range(1, limit+1), lambda x, y : x*y))
[1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]