Elementry question on indeces

Moshe Zadka moshez at math.huji.ac.il
Sun Mar 5 01:28:52 EST 2000


On Sat, 4 Mar 2000, Rick wrote:

> >From the tutorial, on strings and zero relative indeces,
> where word =
> 'HelpA'.
> 
> I have no problem with this, we are asking for 4th entry:
> >>> word[4]
> 'A'
> 
> but it seems to me the following is asking for the 0th, 1th and 2th entries
> (ordinal 1st ,2nd and 3rd) but all we are getting is the zero-th and one-th.
> 
> >>> word[0:2]
> 'He'

The semantics of slices, ranges and xranges are consistent:

from-to means all x's such that from<=x<to






More information about the Python-list mailing list