+ 1

Why numbering starts from 0

I wonder, why is the numbering the elements in a list starts from 0, instead of 1?

13th Jul 2017, 10:40 AM
Onur Ozdemir
5 odpowiedzi
+ 5
Because you're specifying an offset (index) from the first valid position*, not a count (quantity) of items. * often in order to do something with an item at that offset,
13th Jul 2017, 4:28 PM
Kirk Schafer
Kirk Schafer - avatar
+ 2
don't know but there will be some reason.
13th Jul 2017, 11:03 AM
Akash
Akash - avatar
+ 2
Because by default number system of computation start from 0 to 9 and their repetation to form bigger numericals
13th Jul 2017, 11:23 AM
sreeraj thampan
sreeraj thampan - avatar
+ 2
It is due to memory address. C/C++ would have learned you that :p Python are list (I will explain how they are really structure next) so the ID you use is the number of time you'll need to go to the next element starting from the first one. List are a data structure that is made like that : List : | valueOfElement | nextElement //let say it can be None So if you have the list [1,2,3,5], in reality you have : 1->2->3->5 I tried to explain without speaking of memory but if it is still unclear I will gladly add memory explanations :)
13th Jul 2017, 11:26 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 1
0 is a number and is the smallest, within the positive numbers: why shuoldn't you start from 0, when going through the positive numbers in ascending order? edit: think of a marked ruler (credits to Kirk shafer)
13th Jul 2017, 12:51 PM
seamiki
seamiki - avatar