【Python面試真題】- 怎么用Python生成指定長(zhǎng)度的斐波那契數(shù)列 ?
【Python面試真題】- 怎么用Python生成指定長(zhǎng)度的斐波那契數(shù)列 ?
def fibs(x):
result = [0, 1]
for index in range(x-2):
result.append(result[-2]+result[-1])
return result
if name==’main‘:
num = input(‘Enter one number: ‘)
print fibs(num)