[Tutor] Remove a number from a string
tegmine at gmail.com
Tue Aug 23 20:59:46 CEST 2005
On 8/23/05, Shitiz Bansal <shitizb at yahoo.com> 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?
I believe this question to be rather variable in its answer. If all
your strings are of the form "### word word", then you could safetly
use 'split', as in:
>>> s = '347 liverpool street'
l = s.split()
i = int(l)
print "String segment not a number"
But, if your string is also of the form "347-10 liverpool street",
then your problem is more complex.
More information about the Tutor