Fibonacci Sequence

A function that generates the first 10 numbers in the Fibonacci sequence. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. For example, the first 10 numbers are: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34.

image

Another way

def fibonacci(n):
    if( n <= 1):
        return n
    fib_list = [0, 1]
    for i in range(2, n+1):
        j = fib_list[i-1] + fib_list[i-2]
        fib_list.append(j)
    return fib_list