[Tutor] Hi

Alan Gauld alan.gauld at freenet.co.uk
Wed Mar 22 09:39:14 CET 2006

> I got this, Lets say if its mystring[n:m] where n may be another
> number and m may be another number so how will it work in that case,
> so this becomes general and makes more clear
n is the index of the first character and m is the index *beyond* 
the last character

> Lets say if its mystring[3:8] so how will i evaluate it

It will return the characters at indexes 3,4,5,6, and 7.

In other words it operates in the same way as the range

you could get the same set of characters back using

for index in range(n,m):
    print mystring[index]

Does that help?

Alan G
Author of the learn to program web tutor

More information about the Tutor mailing list