[Tutor] Python 101 at devshed.com confusion
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 28 Jun 2001 16:48:52 +0100
> It makes perfect sense to me when using the len() function
> that I get a response that there are 9 characters in the string, but when
> I count through, starting at 0 for the first character, I only come up
with
> eight for the last character too, just like the interpreter did.
Thats right the index runs from 0 to len()-1
> So how come the first example, indexing [3:9] works?
Because you are not using *indexing* you are using *slicing*.
A slice [min:max] runs from min to max-1.
This is explained in more detail in the python tutor in section
"3.1.2 Strings" (Python 2.0 tutor)
Alan g