[Tutor] Better structure?

Alan Gauld alan.gauld at freenet.co.uk
Wed Feb 2 09:35:47 CET 2005


> I don't know who's going crazy here... but I checked that straight
from the
> python 2.4 interpreter...
>
> Python 2.4 (#60, Nov 30 2004, 11:49:19) [MSC v.1310 32 bit (Intel)]
on win32
> Type "help", "copyright", "credits" or "license" for more
information.
> >>> a = "go on long buddy"
> >>> a.lstrip("gonl")
> ' on long buddy'
> >>> a = "go long on log buddy!"
> >>> a.lstrip('gonl')
> ' long on log buddy!'
> >>>
>
> In both cases, lstrip just removed the first word... I don't see how
this
> code is broken.

It removed all the g,o,n & l's up till it found a character
that wasn't in your list - a space. Thats what you told it to do.
If you want the space stripped add one to your list...

Alan G.



More information about the Tutor mailing list