Elements in "lists" are numbered from 0 instead of 1, but why? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Elements in "lists" are numbered from 0 instead of 1, but why?

English is not my mother language, so there may be some mistakes in my expression. Correct me please >>> I would like to know more about Python and English!😄 Thanks for all the reply!

12th Jun 2017, 11:32 AM
pyr_py
pyr_py - avatar
3 Answers
+ 5
Because it's more "natural" in context of variable storage: A list is stored as a list of references to anothers values, say a list of variables, which takes all the same memory space M, each next other. So, your list is stored to an memory address A, wich is the location of the first reference stored in it, then to adress A+M, is the second, then at A+M+M the third, so you can see the natural of the calculation of the adress of one item given its zero starting index i: A+i*M ^^
12th Jun 2017, 4:16 PM
visph
visph - avatar