"Cindy Lee" <cindylee2...@yahoo.com> wrote
...asked to make a function that receives text as an argument
and returns the same text, but with 1 added to each number.
So far I have:

def ReceiveAndReturn():
sentence=raw_input("Give me a sentence with variables in it: ")

The assignment says it should receive the text *as an argument*
That means you don't read it using raw_input.

Its not clear what the adding one to each number bit means.
If we make some assumptions:

"2 cats sat on a mat" -> "3 cats sat on a mat"

but not

"Two cats sat on a mat" -> "Three cats sat on a mat"

In other words we are only detecting strings of decimal digits
not numeric words.

Then we can search the string(a sequence) for consecutive
numbers. Convert them from strings to numbers and add one
Then insert into the output string. Thats the tricky bit! :-)

Have a go, post your code and we will try to help when
you get stuck.

HTH,


--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to