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
Does this look right? Still a little confused
if char.isdigit():
num = int(char) + 1
a_string[index] = str(num)
print a_string
From: Marc Tompkins
To: Ken Baclig
Cc: "tutor@python.org"
Sent: Wednesday, July 20,
July 20, 2011 6:11 PM
Subject: Re: [Tutor] Homework problem
Ken Baclig wrote:
> 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.
What counts as a n