Improve your programming skills

List of Fibonacci in Python and Fibonacci function

Fibonnaci in python by token:

# fibbonaci:
fib_list = [0, 1]
for i in range(10):
    fib_list.append(fib_list[-2] + fib_list[-1])
    print(fib_list)

Or if You want Python function to generate Fibonacci

def funFibonaci(numberElements_in):
    fib_list = [0, 1]
    if numberElements_in == 1:
        return fib_list[-2]
    if numberElements_in == 2:
        return fib_list[-1]
    for i in range(numberElements_in-2):
        fib_list.append(fib_list[-2] + fib_list[-1])
    return fib_list

print(funFibonaci(10))

Leave a comment

Your email address will not be published.