I am currently working on recursion in Python but even though my process is correct I do not get my output format as I wanted.
def fibonacci(n):
if n <= 2:
return 1
else:
return fibonacci(n-1) + fibonacci(n-2)
def fibseries(N):
if N <= 1:
return []
return [fibseries(N-1),fibonacci(N-1)]
a = fibseries(5)
print a
This gives me the output :
[[[[[0], 1], 1], 2], 3]
but I want to get:
[0, 1, 1, 2, 3]
I need to understand the thinking process.