So let's just say I had code that went something like:
x = 'foobar'
and I wanted to print the first half (foo) and then the second (bar). One would think that it would either be written counting the first letter as "0" like the first item on a list -
x = 'foobar'
print x[0:2]
print x[3:5]
-or counting the first letter as "1" :
x = 'foobar'
print x[1:3]
print x[4:6]
But through a bit of trial-and-error, I've discovered that the first value (the one before the " : ") counts from 0, whereas the second value (the one after the " : ") counts from 1. So the
proper code would be:
x = 'foobar'
print x[0:3]
print x[3:6]
I get it now, but why is this? Is there some reason?