[Tutor] creating the equivalent of string.strip()
bob.nienhuis at gmail.com
Mon Oct 1 01:05:48 CEST 2007
BTW, GMail brings up some interesting sponsored links when the subject line
has string.strip in it ( :-0)
On 9/30/07, Alan Gauld <alan.gauld at btinternet.com> wrote:
> "wesley chun" <wescpy at gmail.com> wrote in message
> news:78b3a9580709300102x12cbe392uebb988ed965c7202 at mail.gmail.com...
> >> > I'm not sure how to proceed. My biggest stumbling
> >> > block is how to detect the leading and trailing
> >> > whitespace.
> >> Use indexing.
> >> Try using a while loop.
> >> Or maybe two?
> >> And strings have an isspace method...
> > unfortunately, the isspace() string method only returns True if all
> > chars in the string are whitespace chars and False otherwise, so
> > that's a bummer.
> But the string can be one character long:
> s = 'fred\n'
> print s[-1].isspace() # --> True
> Alan G
> Tutor maillist - Tutor at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor