 I need the answer, I don't know why this output, and I need the explication of itertools | Sololearn: Learn to code for FREE!

+8

# I need the answer, I don't know why this output, and I need the explication of itertools

https://code.sololearn.com/c7dJxwWk5RnT/?ref=app

+9

The accumulate function in the itertools module, by default, will take in an iterable and returns an iterable that keeps a running sum of its items. The original range converted to a list would be; [0, 1, 2, 3, 4, 5, 6, 7] Where the accumulated list returned is; [0, 1, 3, 6, 10, 15, 21, 28] Notice if you start at the 1st element and then add the values of the previous elements that the sum of those values results in the current elements value. The element at index 0 is 0 The element at index 1 is equal to the element at index 0 + the element at index 1. So it is equal to 1 (0+1) The element at index 2 is equal to the sum of elements at index 0 and 1 + the element at index 2. So it is equal to 3 ((0+1)+2) And so on .... https://docs.python.org/3/library/itertools.html https://docs.python.org/3/library/itertools.html#itertools.accumulate

+5