[Tutor] Remove a number from a string

Byron byron at christianfreebies.com
Tue Aug 23 22:03:11 CEST 2005

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:


def removeNums(addr):
    text = addr.split()
    revisedAddr = ""
    for item in text:
            i = int(item)
            revisedAddr += item + " "
    return revisedAddr.strip()

# Test the function...  ;-)
address = "5291 E. 24rd Ave."
print removeNums(address)

More information about the Tutor mailing list