[Tutor] recursive problem

Walter Prins wprins at gmail.com
Thu Sep 9 14:26:58 CEST 2010


On 9 September 2010 12:59, Shashwat Anand <anand.shashwat at gmail.com> wrote:

>
> Let's say n, l = 2, [2, 9, [2, 1, 13, 2], 8, [2, 6]]
> Simply Flatten the list l, which will be then be; flatten(l) = [ 2, [2, 9,
> 2, 1,13, 2, 8, 2, 6 ]
> Now count for n; flatten.count(n)
>
>
This is fine except that the excercise probably has to do with introducing
recursion and scoping, which is unfortunately defeated by this solution.

Roelof, look at what you do with the result of the recursive call  which you
currently assign to test and otherwise ignore -- you want to add this to
count and/or return it...

Walter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100909/326dd36a/attachment.html>


More information about the Tutor mailing list