Member Avatar


I know this maybe easy but I need help with creating a fibonacci sequence array from a to b.
This is my code so far:

def FibL(a,b):
        list = []
        if a == 0:
            return 0
        elif a == 1:
            return 1
            return FibL(a-1) + (a-2)
        for i in range(a, b+1):
        return list

When I test it with print(FibL(1,6)), it returns 1.
I need it to return [1, 1, 2, 3, 5, 8]

No mystery here. When it sees that a == 1, it returns immediately with a value of 1. It won't get to the list.append code.

Oh my goodness, you are mixing a recursive fibonacci number function with an attempt to make a sliced list. A recipe for disaster.