[Tutor] A recursion question
Asokan Pichai
pasokan at talentsprint.com
Sat Nov 19 04:03:49 CET 2011
Another way to do that is to avoid any intermediate variables altogether
That may be easier to understand YMMV
def counter(mylist, val):
if len(mylist == 0):
return 0
if mylist[0] == val:
return 1 + counter(mylist[1:], val)
else:
return counter(mylist[1:])
Asokan Pichai
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20111119/8c9206a0/attachment.html>
More information about the Tutor
mailing list