[Tutor] Homework problem

Ken Baclig kbaclig at yahoo.com
Wed Jul 20 23:54:52 CEST 2011


Hi,

I'm trying to make a function that receives text (a string) as an argument and returns the same text (as string), but with 1 added to each word that is a number.

I need help getting started.

So far, I have:

def FindNumbers(a_string):

    for index, char in enumerate(a_string):
        if char.isdigit():
a_string[index] = 


def Test():

    sometext = "I got 432 when I counted, but Jim got 433 which is a lot foronly 6 cats, or were there 12 cats?"
    
    FindNumbers(sometext)

Test()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110720/db519cf1/attachment.html>


More information about the Tutor mailing list