def GenerateFibonaci(x):
if(x == 0):
return 0
elif(x == 1):
return 1
else:
for i in range(x):
return GenerateFibonaci(x-1) + GenerateFibonaci(x-2)
print(GenerateFibonaci(x))
I'm attempting to write a program GenerateFibonaci(x) that takes one input and prints a listed fibonaci sequence depending on the length of x.
Here's what I get as an output, only one value instead of a list:
>>> GenerateFibonaci(6)
8
This is what I'm trying to get it to look like:
>>> GenerateFibonaci(5)
[0,1,1,2,3]
>>> GenerateFibonaci(8)
[0,1,1,2,3,5,8,13]
Not sure if I need to add a list statement or a new nested loop? Any help would be greatly appreciated.