What is the logic behind programming languages 0-indexing?

582 views

As someone who primarily uses R, I don’t understand why Python indexes lists starting from 0. I’m very slow at simple mental calculations and doing something like subsetting an array in Python often takes me several extra seconds.

I think I read that it has something to do with memory, but thats so much less of a consideration for people who only use high level languages.

In: Technology

9 Answers

Anonymous 0 Comments

The other responses are all correct, but if you want a shortened version, think about how a number is stored. It’s stored in bits; 1’s and 0’s. You can have four bits that are all 0’s: 0000. If you start your index with 1 (0001), you miss out on an extra spot in the array.

You are viewing 1 out of 9 answers, click here to view all answers.