I am trying to print the fibonacci series using lists in python. This is my code:
T = int(raw_input())
N = [int(raw_input()) for i in range(T)]
N[:] = [x-2 for x in N]
L1 = [1, 1]
L2 = []
for j in N:
for k in range(j):
L1.append(L1[-1]+L1[-2])
L2.append(L1)
print L2
Here, T denotes the number of test cases. N denotes the number of elements in the fibonacci series.I need to print the required output of the fibonacci series for each test case.
Input: 2 4 5
Output for the code above:
[[1, 1, 2, 3, 5, 8, 13], [1, 1, 2, 3, 5, 8, 13]]
However the output that I want to print is:
[1, 1, 2, 3], [1, 1, 2, 3, 5]]
Please let me know how I should proceed on this