I am trying to use Fibonacci series and get Cubes of the series. My Fibonacci function is giving an output but I want that output to be in a List form. Following is my code
cube = lambda x : x ** 3
def fibonacci(n):
a = 0
b = 1
count = 0
if n < 0:
print("Incorrect input")
elif n == 0:
return a
elif n == 1:
return b
else:
while count < n:
print(a)
c = a + b
a = b
b = c
count += 1
if __name__ == "__main__":
n = int(input())
print(list(map(cube,fibonacci(n))))
I am getting the following output with error:
6
0
1
1
2
3
5
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-38-58624b7f0dd2> in <module>
1 if __name__ == "__main__":
2 n = int(input())
----> 3 print(list(map(cube,fibonacci(n))))
TypeError: 'NoneType' object is not iterable
I am very new to coding. Please help!