Bizarre behavior of the 'find' method of strings

Chris Angelico rosuav at
Wed Aug 10 22:14:30 EDT 2011

On Thu, Aug 11, 2011 at 2:48 AM, MRAB <python at> wrote:
> Python uses half-open ranges, which means that the start position is
> inclusive and the end position is exclusive.

Or if you prefer: Python identifies positions between characters,
rather than characters. And I agree that it's better than the
alternative - in fact, I wish other systems could work the same way
(eg Bible references). If you think about position 0 being the very
beginning of the string, and position len(s) being the very end, then
you slice the string from position to position and take the characters
between. When you index the string for a particular character, you aim
at a position and take the character after it.

Chris Angelico

More information about the Python-list mailing list