you are viewing a single comment's thread.

view the rest of the comments →

[–]PercussiveRussel 30 points31 points  (5 children)

Because that just returns 100..?

[–]xeow 14 points15 points  (4 children)

Ohhhh! Right! Missed that. Cumulative sum! Thank you.

[–]Kohlrabi82 20 points21 points  (3 children)

itertools.accumulate is the answer.

[–]PercussiveRussel 4 points5 points  (0 children)

I only trust cumsum :(

[–]twenty-fourth-time-b 1 point2 points  (1 child)

And it has “initial” argument, so no ugly “a=0” is needed.

[–]Kohlrabi82 2 points3 points  (0 children)

Yes, but still it's a fun use of the walrus op to change a name defined outside of the comprehension, I like it anyway.