May-15-2021, 11:15 AM
(This post was last modified: May-15-2021, 11:28 AM by Yoriz.
Edit Reason: Added code tags
)
Hi Guys,
I am a Python beginner and trying to write a code for Fibonacci sequence.
I wrote the following code and got a following result: [1, 1, 3, 5, 8, 13, 21, 34, 55, 89]
I was expecting "2" to be included between second and third number...
Can anyone explain what is wrong with this code?
Thank you!
Yasunaga
I am a Python beginner and trying to write a code for Fibonacci sequence.
I wrote the following code and got a following result: [1, 1, 3, 5, 8, 13, 21, 34, 55, 89]
I was expecting "2" to be included between second and third number...
Can anyone explain what is wrong with this code?
Thank you!
Yasunaga
def Fibo(n): a,b=1,1 if n==0: return a elif n==1: return b else: for x in range (n): a,b = b, a+b return b Fibonacci=list([Fibo(n) for n in range(0,10)]) print(Fibonacci)