Member Avatar for knd15

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
        else:
            return FibL(a-1) + (a-2)
        for i in range(a, b+1):
            list.append(i)
        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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.