You are viewing a single comment's thread. Return to all comments →
cube = lambda x: x ** 3
def fibonacci(n): # return a list of fibonacci numbers sequence = [0, 1]
while len(sequence) < n: sequence.append(sequence[-1] + sequence[-2]) # Fix the index here return sequence[:n]
if name == 'main': n = int(input() # Prompt user to input the value of n print(list(map(cube, fibonacci(n))))
Seems like cookies are disabled on this browser, please enable them to open this website
Map and Lambda Function
You are viewing a single comment's thread. Return to all comments →
cube = lambda x: x ** 3
def fibonacci(n): # return a list of fibonacci numbers sequence = [0, 1]
if name == 'main': n = int(input() # Prompt user to input the value of n print(list(map(cube, fibonacci(n))))