0

Help. Please explain

x = list(range(5,6)), so x = [5]. why? shouldn't it be [4]?

19th Jul 2018, 12:42 AM
Brian Gonzalez
Brian Gonzalez - avatar
4 Answers
+ 2
Brian Gonzalez , the first argument in the range function is the 'start' while the second is the 'stop'. In your code snippet, the output is x = [5] Examples: x = list(range(5,9)) x = [5, 6, 7, 8] x = list(range(5)) x = [0, 1, 2, 3 ,4] If there's only one argument, like the above example, that will be the stop and the start will be 0.
19th Jul 2018, 1:01 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar
+ 1
Thank you😄
19th Jul 2018, 1:03 AM
Brian Gonzalez
Brian Gonzalez - avatar
0
Just read the lesson again and understood. I'm dumb
19th Jul 2018, 12:44 AM
Brian Gonzalez
Brian Gonzalez - avatar
0
You're welcome.👍
19th Jul 2018, 1:05 AM
Jonathan Pizarra (JS Challenger)
Jonathan Pizarra (JS Challenger) - avatar