def fib_loop(n):
a,b=0,1
for i in range(n+1):
a,b=b,a+b
return a
f = int(input("Enter a number: "))
for i in range(f):
print(fib_loop(i),end=' ')
这个是求斐波那契数的题,输出要求用逗号隔开,我加后一直报错,print应该怎么改?
def fib_loop(n):
a,b=0,1
for i in range(n+1):
a,b=b,a+b
return a
f = int(input("Enter a number: "))
for i in range(f):
print(fib_loop(i),end=' ')
def fib_loop(n):
a,b=0,1
for i in range(n+1):
a,b=b,a+b
return a
f = int(input("Enter a number: "))
for i in range(f):
if i>0:
print(',',end=' ')
print(fib_loop(i),end='')