我不知道为什么它给我这个错误......它说给我错误的部分是previousFirst + previousSecond = previousSecond
. 如果您想知道目标是打印出用户想要打印出的尽可能多的斐波那契数。
def fibbonaci():
fibbNumber = input("How many Fibonacci numbers should I print for you?")
fibbNumber = int(fibbNumber)
global counter
counter = 0
global previousFirst
previousFirst = 0
global previousSecond
previousSecond = 1
global previousSaved
previousSaved = 1
while (counter < fibbNumber):
previousSaved = previousSecond
previousFirst + previousSecond = previousSecond
print (previousFirst)
print (previousSecond)
counter += 1
fibbonaci()