On Jul 30, 3:48 pm, beginner <[EMAIL PROTECTED]> wrote: > Hi, > > If I have a number n and want to generate a list based on like the > following: > > def f(n): > l=[] > while n>0: > l.append(n%26) > n /=26 > return l > > I am wondering what is the 'functional' way to do the same. >
Recursion is common in functional programming: def f(n, l=None): if l == None: l = [] if n > 0: return f(n/26, l + [n%26]) else: return l print f(1000) -- Hope this helps, Steven -- http://mail.python.org/mailman/listinfo/python-list