List indexing inconcistencies

I personally am used to other languages (js and python), and in those languages, the first item in a list is indexed as 0. So the second item would have an index of 1, and so on. However, in ai2, the first item in a list is indexed as 1. I found this out rather painfully while creating my app, and since I couldn’t test it at that time, I didn’t find this a problem until I had coded every part that had lists in it.

So I had to go back and fix all of the indexes from 0 to 1 and so on.

Anyone have any insight on why this is? I think it would be helpful for developers who come from other backgrounds to have the first index be 0.

The first item of a List is indexed as 1. Yes, this is different from other programming languages and discerning to users coming from other compilers and languages.


do you want to simulate 0 index.
I would not, just adjust to the paradigm.


AI2 is meant for first time learners, who count from 1 by popular (non-programmer) convention.

Okay thanks I just wanted a good reason.

That makes sense.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.