[Tutor] lstrip() question

Tim Johnson tim at johnsons-web.com
Mon Feb 2 15:57:55 EST 2004

Hello All:
    I'd like to remove all leading occurance of a html break tag
in  a string such that
"<br><br>test" => "test"
"<br>test<br>this" =>"test<br>this"

It appears that lstrip() will not do this
as this console session using version 2.2.2
seems to demonstrate:
>>> tmp1 = 'real estate broker courtesy'
>>> tmp2 = tmp1.lstrip('<br>')
>>> tmp2
'eal estate broker courtesy'

It looks like '<br>' is being treated as
a set rather than a substring. 
(that's why the 'r' was removed)

Is there a builtin
python method to strip leading substrings? Or do
I have to do something using startswidth()?

Before I re-invent an existing wheel....

Tim Johnson <tim at johnsons-web.com>

More information about the Tutor mailing list