On 13.09.2012 21:01, 88888 Dihedral wrote: > def powerlist(x, n): > # n is a natural number > result=[] > y=1 > for i in xrange(n): > result.append(y) > y*=x > return result # any object in the local function can be returned
def powerlist(x, n):
result=[1]
for i in xrange(n-1):
result.append(result[-1]*x)
return result
def powerlist(x,n):
if n==1:
return [1]
p = powerlist(x,n-1)
return p + [p[-1]*x]
--
http://mail.python.org/mailman/listinfo/python-list
