Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
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? -- Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-r

Re: Accumulate , Range and Zeros

2019-07-13 Thread Frank Millman
On 2019-07-13 11:54 AM, 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? That is an easy one. By de

Re: Accumulate , Range and Zeros

2019-07-13 Thread Dan Sommers
On 7/13/19 5:54 AM, 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))

Re: Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
@Frank So simple. Thanks! Abdur-Rahmaan Janhangeer http://www.pythonmembers.club | https://github.com/Abdur-rahmaanJ Mauritius -- https://mail.python.org/mailman/listinfo/python-list

Re: Accumulate , Range and Zeros

2019-07-13 Thread Thomas Jollans
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

Re: Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
@Thomas thought was a generator bug since instead of returning the usual nums it was returning 0 0 0 ... -- https://mail.python.org/mailman/listinfo/python-list

Re: Accumulate , Range and Zeros

2019-07-13 Thread Chris Angelico
On Sat, Jul 13, 2019 at 10:02 PM Abdur-Rahmaan Janhangeer wrote: > > @Thomas thought was a generator bug since instead of returning the usual > nums it was returning 0 0 0 ... When you find a bug or strange bit of behaviour, first make sure you can reproduce it. Then create a small, self-containe

Re: Accumulate , Range and Zeros

2019-07-13 Thread Abdur-Rahmaan Janhangeer
oh not a real bug, i thought the effect had to do with generator working rather a simple times 0 Abdur-Rahmaan Janhangeer Mauritius On Sat, 13 Jul 2019, 16:24 Chris Angelico, wrote: > On Sat, Jul 13, 2019 at 10:02 PM Abdur-Rahmaan Janhangeer > wrote: > > > > @Thomas thought was a generator bug

Re: Books for Python 3.7

2019-07-13 Thread RIchy M
On Friday, July 12, 2019 at 7:34:10 PM UTC-4, Louis Krupp wrote: > On Fri, 12 Jul 2019 07:36:54 -0700 (PDT), mok...@gmail.com wrote: > > >Can anyone help me. > >New to Python. > >Installed version 3.7 > >I purchased the "Python for Dummies" book But this book was written for an > >older version o