Hi Tadziu, > > second parameter that gives an empty string, unlike the > > [startindex, endindex) interval where endindex is exclusive, > > e.g. Python. > > But that's not to say that the python way is in any way > more intuitive or useful. Example: > > >>> print [1,2,3,4,5,6,7,8][-1] > --> 8 > >>> print [1,2,3,4,5,6,7,8][-2:-1] > --> [7] > > which makes negative indices pretty useless for retrieving > a subrange that includes the last element...
If the colon is given then either or both of the indices can be omitted. >>> s = 'abcdefghij' >>> s[3], s[:3], s[3:], s[-3:], s[:] ('d', 'abc', 'defghij', 'hij', 'abcdefghij') The other nice thing about [) is that you can shuffle the indexes along and cover the whole array, i.e. the end index last time becomes the start index this time. >>> s = 'abcdefghij' >>> s[0:3], s[3:6], s[6:9], s[9:12] ('abc', 'def', 'ghi', 'j') [) has become the norm in "new" languages? https://en.wikipedia.org/wiki/Interval_%28mathematics%29#Notations_for_intervals Cheers, Ralph.