[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
Win7Pro
>>> str = "0123456789"
>>> str[-1]
'9'
>>> str[-3:-1]
'78'
>>> str[-3:]
'789'
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?
--
boB
More information about the Tutor
mailing list