[Tutor] Recursive user input collection problem
alan.gauld at btinternet.com
Thu Oct 15 19:46:43 CEST 2009
"William Witteman" <yam at nerd.cx> wrote
>>You need a loop, and putting a while True: around the whole thing
>>solves it nicely. Don't *call* the function again, just loop back
>>and do the operation again. That's what loops are for.
> True, that's why my code currently looks like this:
Personally I don't think recursion is a problem in this context.
You would need a pretty dumb user to get it wrong 1000 times
(Pythons default recursion limit). So although a loop is the
more pythonic idiom a recursive solution here is fine in my
But that may just be because I'm (yet again) playing with Lisp
and therefore thinking recursively about problems rather
than thinking loops.
Author of the Learn to Program web site
More information about the Tutor