>> s = ' '.join(s.split()[1:])
>
> or just
> s = s.split(None, 1)[1]
Neat, I hadn't noticed the maxsplit parameter before.
Alan G.
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
Alan G wrote:
>>Suppose i have a string '347 liverpool street'.
>>I want to remove all the numbers coming at the starting of the
>>string.
>>I can think of a few ways but whats the cleanest way to do it?
>
>
> If you know they are always a contiguous string themn a simple split()
> call will do
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the
> string.
> I can think of a few ways but whats the cleanest way to do it?
If you know they are always a contiguous string themn a simple split()
call will do it:
s = ' '.join(s.sp
Shitiz Bansal wrote:
> Hi,
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the string.
> I can think of a few ways but whats the cleanest way to do it?
>
> Shitiz
Here's a function that can do what you're wanting to accomplish:
By
Shitiz Bansal wrote:
> Hi,
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the string.
> I can think of a few ways but whats the cleanest way to do it?
With str.lstrip():
>>> '347 liverpool street'.lstrip('0123456789')
' liverpool st
On 8/23/05, Shitiz Bansal <[EMAIL PROTECTED]> wrote:
> Hi,
> Suppose i have a string '347 liverpool street'.
> I want to remove all the numbers coming at the starting of the string.
> I can think of a few ways but whats the cleanest way to do it?
>
> Shitiz
>
I believe this question to be