[Tutor] Remove a number from a string

Kent Johnson kent37 at tds.net
Tue Aug 23 23:00:24 CEST 2005

Alan G wrote:
>>Suppose i have a string '347 liverpool street'.
>>I want to remove all the numbers coming at the starting of the 
>>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.split()[1:])

or just 
s = s.split(None, 1)[1]

As Luis pointed out, you may want to define your requirements a bit more closely to help choose between the different approaches. For example, what do you want to get from
347-10 liverpool street
347A liverpool street
347 A liverpool street
123 45th street
#1 liverpool street


More information about the Tutor mailing list