3 ms·
By now we've been doing for (int i=0; i<13; i++) { whatever(array[i]); } and def printHello(): print("hello world"[0:5]) for d
by ajuc 3y ago
By now we've been doing
for (int i=0; i<13; i++) {
whatever(array[i]);
}
and
def printHello():
print("hello world"[0:5])
for decades. No point vastly messing up consistency for minimal gain. BTW notice how in both cases we count to n elements despite using 0..n-1 indexing. You don't, in fact - need to put 12 anywhere if you mean 13 elements.
- jacknews 3y agoBut whatever[1] gives the second item, and the last item, of 13, is whatever[12] fortran has been 1-based since well before these examples. The point is there is no one true way, it's a trade-off.