On Wednesday 02 March 2005 06:03, actuary77 wrote:
> It now makes sense if I write it, (simple):
>
> def rec2(n):
> if n == 0:
> return []
> else:
> return [n] + rec2(n-1)
Or, if you're not interested in a recursive function to do this job (which
should be way faster..
actuary77 wrote:
I am trying to write simple recursive function to build a list:
def rec(n,alist=[]):
_nl=alist[:]
print n,_nl
if n == 0:
print n,_nl
return _nl
else:
_nl=_nl+[n]
rec(n-1,_nl)
_nl=[]
_nl=rec(4)
print _nl
### shouldn't this work?
_nl=re