python
def fibonacci_sequence(n):
sequence = [0,1]
for i in range(2,n):
next_number = sequence[i-1] + sequence[i-2]
sequence.append(next_number)
return sequence
# 示例输入
n = 10
# 调用函数并打印结果
print("斐波那契数列前", n,"项为:", fibonacci_sequence(n))
标签:并打印,sequence,python,number,调用函数,next,fibonacci From: https://blog.51cto.com/u_16058927/7150494