It would be "ercal". The first number n denotes the position where we start. The first position is always zero. So 3 would be the letter at the 4th position which is e. The second number is I guess what confused you. m denotes where we end, counted the same way but by having 1 for the first position. 8 in your case would then be l (8th actual position).
Try this mystring[3:4] to understand the working -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Kaushal Shriyan Sent: Wednesday, March 22, 2006 12:45 PM To: tutor@python.org Cc: Danny Yoo Subject: Re: [Tutor] Hi On 3/22/06, Danny Yoo <[EMAIL PROTECTED]> wrote: > > > I am new to python and I am going through the URL > > http://www.ibiblio.org/obp/thinkCSpy/index.htm, At the moment I am going > > through the Chapter 7 Strings, I am stuck with understanding slice which > > is a part of a String, I am not able to understand how it functions > > Hello, > > > A "slice" takes a string and returns a "substring" of that string. For > example, if we have a string like: > > ###### > >>> mystring = "supercalifragilisticexpialidocious" > ###### > > then we can select different portions of the string by indicating the > start and end positions. For example, the first ten characters of > mystring can be extracted using a slice: > > ###### > >>> mystring[0:10] > 'supercalif' > ###### > > > Is this what you are confused about? > > Please give us more details on where you're getting stuck, and we will do > what we can to help clarify. > > > Please continue to reply to '[EMAIL PROTECTED]': do not email me > directly. Although I may not personally have the time to answer, I'm sure > at least one of the other helpers on the list do, so by continuing the > conversation on python-help, we'll be able to guarantee that your > questions are not lost. > > Thanks Danny Yoo 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 Lets say if its mystring[3:8] so how will i evaluate it Thanks for all the help Regards Kaushal _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor