Range definition -needs correction | Sololearn: Learn to code for FREE!

+1

Range definition -needs correction

Range(10) generates all the integer numbers from zero up to, BUT NOT INCLUDING 10. Description NEEDS CORRECTION. I.e. list (Range(N)) is [0, 1, ..., N-1]

5/12/2018 10:49:28 AM

Stoyan

5 Answers

New Answer

+13

which description??? 🤔🤔🤔 https://www.sololearn.com/learn/Python/2434/?ref=app

+2

range definition is correct :D range() (and Python in general) is 0-index based, meaning list indexes start at 0, not 1. eg. The syntax to access the first element of a list is mylist[0]. Therefore the last integer generated by range() is up to, but not including, stop. For example range(0, 5) generates integers from 0 up to, but not including, 5.

+2

yes, that one, and the next with two arguments. ît includes the first argument, but then UP TO BUT NOT INCLUDING THE SECOND

+1

ok I explain you this by making an list x=[1,2,3,4,5] the length of this list is 5 but to access fifth element we do like this x[4] which indicates to 5th element it is because index start with 0 so 0 1 2 3 4 this is called as range (0,5) in counting they are 5 but it start from 0 so it not included the last 5

+1

I understand and only trying to help you teach what you just wrote. People are learning Python here, me too, and when you say Range(10) produces all the numbers up to 10, without qualification, most people would understand INCLUDING 10.