Positions in a sequence refer to locations between the values. Positions are numbered from left to right starting at 0. You can also refer to positions in a sequence using negative numbers to count from right to left: position -1 is the position before the last element, position -2 is the position before the next-to-last element, and so on.
Here are all the positions of the string
To extract a single element from a sequence, use an
expression of the form
is a sequence, and
is an integer
value that selects the element just after that position.
>>> s 'a' >>> s 'e' >>> s Traceback (most recent call last): File "<stdin>", line 1, in ? IndexError: string index out of range
The last line is an error; there is nothing after position
5 in string
>>> L 0 >>> t 'x'