[Tutor] -Recursive Functions (fwd)

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Sun Jun 1 18:50:02 2003


[Forwarding to tutor@python.org; please keep tutor@python.org in CC in
your replies; this lets others give sugestions or make corrections.]

---------- Forwarded message ----------
Date: Sun, 01 Jun 2003 19:12:40 +0000
From: Evripides Loizides <loizie@hotmail.com>
To: dyoo@hkn.eecs.berkeley.edu
Subject: Re: [Tutor] -Recursive Functions


i ma having problem to understand how to aply the recursion function to
my problem

i understand what a recursive function does. the problem im facing is to
apply it on my problem here what i have right now and let me know if i am
in the rigth direction ok

thanks:

import string
num=len(myString)

def stringToNum(aString):
   (i have to put a condition over here .)

      if myString[n-1].isdigit():
         sum=sum+int(myString[n-1])
        n=n+1
   print sum


 myString = raw_input("Enter a string: ")
print stringToNum(myString)







>From: Danny Yoo
>To: Evripides Loizides
>CC: Tutor
>Subject: Re: [Tutor] -Recursive Functions
>Date: Sun, 1 Jun 2003 09:52:09 -0700 (PDT)
>
>
>On Sun, 1 Jun 2003, Evripides Loizides wrote:
>
> > i did wrote the program using while loop that i am more familiar
with.i
> > am asking for anybody to solve my problem im just looking to find if
> > anybody can help me with the recirsive functions.
>
>Hi Evripides,
>
>
>A few of us have already given you examples of recursive functions, but
>that doesn't seem to be working
>
>Our dilemma is that we really can't read your mind: we can't easily see
>what the problem is. Our own recourse is to probe by asking questions.
>
>Can you try to explain to us what problems you're having with recursion?
>Is it the definition of "recursion" that you're having trouble with, or
>are you having problems applying it?
>
>Let's say that we're working on a similar problem: if you were to try
>writing a recursive function that returns the number of vowels in a
word,
>how would you go about it?
>
>
>Try writing some simpler recursive functions and feel free to show them
to
>us, even if they don't work quite right. Once we see examples of your
>recursive functions, we can then get a better handle on things we can do
>to help make recursion make more sense for you.
>
>Good luck to you.
>
>
>_______________________________________________
>Tutor maillist - Tutor@python.org
>http://mail.python.org/mailman/listinfo/tutor

________________________________________________________________________________