[Tutor] Re Help with this script

Alan Gauld alan.gauld at freenet.co.uk
Wed Apr 27 00:51:35 CEST 2005


> OK the situation is that I haven't still found out what the answer
is, I
> have noticed in the other hand that if I select the option "a" let's
say 4
> times, I need to enter the option "f" 4 times. I am curious to know
what the
> solution is. I have read your chapter on recursion but that did not
clear
> anything.

OK, basically the problem is that you have unintentionally created
a recursive function. Every time you call it you create a new copy
of the function. When you exit the function you wind up back in
the previous copy. So as many times as you call the function you
have to exit it the same number of times to get back to the top
of your program.

Have a think about it, and see if that makes sense.

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list