I often change the parameters in the code to better understand. This output is unclear to me? | Sololearn: Learn to code for FREE!
+ 12

I often change the parameters in the code to better understand. This output is unclear to me?

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

13th Mar 2018, 10:21 PM
Vuńćko/–í—É—á–ļ–ĺ/Vuchko
Vuńćko/–í—É—á–ļ–ĺ/Vuchko - avatar
2 Respuestas
+ 4
Range() with 1 parameter gives you a list of integers from 0 going up to but not including the parameter. Since -8 < 0, range(-8) doesn’t do anything. If you pass a second parameter to the range function, the first number replaces 0 as the start number, then it goes up to but not including the second parameter. If you do range(-8, 0) you should see a different result.
13th Mar 2018, 10:39 PM
Mike Shaw
Mike Shaw - avatar
+ 2
The accumulate function goes something like this: 0 = 0 1 = 0 + 1 3 = 0 + 1 + 2 6 = 0 + 1 + 2 + 3 10 = 0 + 1 + 2 + 3 + 4 15 = 0 + 1 + 2 + 3 + 4 + 5 and so on... while the takewhile function iterates through the list elements and gets that element if it satisfies the given expression in the function.
13th Mar 2018, 10:35 PM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar