Should I think of indexing or offset (that starts from 0 rather than 1 in python) not as the number of the character itself, but | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Should I think of indexing or offset (that starts from 0 rather than 1 in python) not as the number of the character itself, but

I read somewhere that this offsetting is because of the spaces not number of characters or due to some kind of tradition in programming languages.... e.g. my_string = 'fugu-sashi' my_string[0] output is 'f' Here you can see that.. between start & the character-'f' we have zero space, so it is indexed as '0' & so on..

10th Sep 2017, 3:55 PM
prantik chakraborty
prantik chakraborty - avatar
1 Answer
+ 7
I wouldn't overthink it too much :) Indexes in Python start from 0, that's it. It kind of grows on you after a while... ;)
10th Sep 2017, 8:19 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar