a little bit of recursion
Gregor Lingl
glingl at aon.at
Tue Oct 21 17:25:13 EDT 2003
Skip Montanaro schrieb:
> Dominik> def rek(N, L):
> Dominik> N = N + 1
> Dominik> if N >= 9: return L
> Dominik> else: return rek(N, L = L.append(N))
>
> In the recursive calls, L is None. Just pass L as the second arg:
>
> def rek(N, L):
> N = N + 1
> if N >= 9:
> return L
> L.append(N)
> return rek(N, L)
>
> Skip
>
Nice, but will not append 9 as desired
Gregor
>
More information about the Python-list
mailing list