Accumulate , Range and Zeros

Thomas Jollans tjol at tjol.eu
Sat Jul 13 06:44:15 EDT 2019


On 13/07/2019 11:54, Abdur-Rahmaan Janhangeer wrote:
> Greetings,
> 
> Given this snippet
> 
> from itertools import *
> import operator
> 
> 
> x = [1, 2, 3] # [0, 1, 2, 3, ..., 10]
> 
> y = accumulate(x, operator.mul)
> 
> print(list(y))
> 
> why does x = list(range(5)) produces only zeros?

What would you expect it to produce?



More information about the Python-list mailing list