为什么这样写不对?
class Fib(object):
def __call__(self, n):
L=[]
if n==1:
L=[0]
elif n==2:
L=[0,1]
else:
L=[0,1]
for i in range(2,n):
L.append(L[i-1]+L[i-2])
f = Fib()
print f(10)
输出结果是 None
class Fib(object):
def __call__(self, n):
L=[]
if n==1:
L=[0]
elif n==2:
L=[0,1]
else:
L=[0,1]
for i in range(2,n):
L.append(L[i-1]+L[i-2])
f = Fib()
print f(10)
输出结果是 None
2020-08-03
举报