SChitti at manh.com
Wed Mar 22 08:47:21 CET 2006
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
From: tutor-bounces at python.org [mailto:tutor-bounces at python.org] On
Behalf Of Kaushal Shriyan
Sent: Wednesday, March 22, 2006 12:45 PM
To: tutor at python.org
Cc: Danny Yoo
Subject: Re: [Tutor] Hi
On 3/22/06, Danny Yoo <dyoo at hkn.eecs.berkeley.edu> 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
> > through the Chapter 7 Strings, I am stuck with understanding slice
> > is a part of a String, I am not able to understand how it functions
> A "slice" takes a string and returns a "substring" of that string.
> 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]
> Is this what you are confused about?
> Please give us more details on where you're getting stuck, and we will
> what we can to help clarify.
> Please continue to reply to 'python-help at python.org': do not email me
> directly. Although I may not personally have the time to answer, I'm
> 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
Tutor maillist - Tutor at python.org
More information about the Tutor