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:

Byron
---

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

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




_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to