[Tutor] "Philosophical" question about string slicing from end of a string

boB Stepp robertvstepp at gmail.com
Mon Nov 24 19:32:27 CET 2014

Python 2.7.8

>>> str = "0123456789"
>>> str[-1]
>>> str[-3:-1]
>>> str[-3:]

I understand that the above is "the way it is" in Python, but I am
puzzled why the designers did not choose that str[-3:-1] returns
'789', especially since str[-1] returns '9'. What is the reason for
choosing Python's actual behavior?


More information about the Tutor mailing list