[Tutor] Recursion always returns None
Alan Gauld
alan.gauld at btinternet.com
Tue Aug 28 18:13:21 CEST 2012
On 28/08/12 16:51, Dharmit Shah wrote:
> @Dave Angel : Thank you for the loop idea. It didn't strike me at all.
>
For some reason some beginners seem to find recursion a natural pattern.
Many others, including quite experienced programmers find it a mind
bending concept.
But as a general rule, where you want to repeat an naction a number of
times thing loops. If you know in advance how many times to repeat (eg
all the items in a list) think 'for' loops, if you don't know how often
(eg until some input condition is met) think 'while' loops.
HTH,
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list