+ 2

list(range(3,8)) produces an output from [3,4,5,6,7] why not upto 8?

1st Aug 2016, 7:56 AM
Vaibhav
Vaibhav - avatar
7 Antworten
+ 5
You can understand easily: range takes an argument (number 8, for example) as the length. So you have: 0, 1, 2, 3, 4, 5, 6 and 7. But when you specify another argument, before the previous one, Python expects your starting point. In that particular case number 3. Thus when you print again you're just hiding numbers 0, 1 and 2. Hope it develops your understanding.
3rd Aug 2016, 1:15 AM
Henrique Santana
Henrique Santana - avatar
+ 2
the range function works from a number (mostly 0) TO the end wich means excluding the last number
1st Aug 2016, 9:10 AM
Tom Post
Tom Post - avatar
+ 2
in the comand of range (3,8) means between 3 to 8 . thats why your output comes 3,4,5,6,7 .
29th Aug 2016, 5:12 AM
Shubham Agnihotri
Shubham Agnihotri - avatar
0
in a scientific collection range the threshold is displayed but not the upper limit that's why so
24th Sep 2016, 12:24 PM
Ahmed Kamal
Ahmed Kamal - avatar
0
the threshold of every counting is zero but can u tell the ending of a counting. u can't imagine even then why so computer
24th Sep 2016, 12:27 PM
Ahmed Kamal
Ahmed Kamal - avatar
- 1
can u plzz explain
1st Aug 2016, 9:55 AM
Vaibhav
Vaibhav - avatar
- 1
sharma hope u got the answer
24th Sep 2016, 12:28 PM
Ahmed Kamal
Ahmed Kamal - avatar