所以我嘗試使用input
號碼打印斐波那契序列。我不知道如何在我的代碼中輸入數字。從輸入號碼打印斐波那契
def fibonacci(n):
a,b=0,1
while(a<n):
print(a,end=' ')
a,b=b,a+b
print()
fibonacci(fibo_entry=input("enter number"))
我得到這個錯誤:
TypeError Traceback (most recent call last)
<ipython-input-113-d552685b93df> in <module>()
7 a,b=b,a+b
8 print()
----> 9 fibonacci(fibo_entry=input("enter number"))
TypeError: fibonacci() got an unexpected keyword argument 'fibo_entry'
非常感謝!顯式方法起作用並且看起來很簡單。 –
@KrithikaKrishnan沒問題。請不要忘記[接受](http://stackoverflow.com/help/accepted-answer)/ upvote有用的答案。 :) – MSeifert
嗨@KrithikaKrishnan *如果*答案解決了您的問題,如您所示,請考慮接受答案(在左側上/下箭頭下方勾選大「V」)。這是指出答案適用於您的適當方式,並增加您未來可以獲得良好答案的機會。 –