[Python] Python: Fibonacci Sequence

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I'm just trying to improve my programming skill by making some basic functions.

    I want to fill a list with fibonacci values, but I think my code gives the sum of all the numbers put together and prints that instead..

    numberlist = []
    i = 0
    for i in range(20):
    numberlist.append(i)

    print numberlist

    fibonaccinumbers = []

    for n in numberlist:
    def fib(n):
    a, b = 0, 1
    for i in range(n):
    a, b = b, a + b
    return a
    a = fib(n)
    fibonaccinumbers.append(a)


    print a


    Where have I gone wrong?

    Continue reading...

Compartilhe esta Página