[Tutor] Sequencing

Noah Hall enalicho at gmail.com
Thu May 19 15:20:49 CEST 2011


On Thu, May 19, 2011 at 11:10 AM, Cindy Lee <cindylee2321 at yahoo.com> wrote:
> Sorry I am still lost. So I am suppose to use a string? Something like:
> (just not sure is the right string...)

Well, no. The assignment you've been given states the you need to
define a function that takes a string as an argument, for example
>>> def take_string(some_string):
...     return some_string
...
>>> take_string("Hello")
'Hello'

There, I have defined a function that takes a string as input, and
returns the same string unmodified.

What your assignment then says, however, is that you need to retrieve
numerical values from the string argument, modify them by adding one,
then return the new string.

So, to break it down for you -



1) Take a string value
2) Go through the string, taking each character one at a time. Create
an empty string to hold characters
3) If character is numerical, complete the number from the string and
add one to the total value, then skip the extra chars used to complete
the number, storing the new value in the empty string
4) If character is not numeric, store the character in the string
5) Return the created string


More information about the Tutor mailing list