Michel Tamer
Michel Tamer

Reputation: 341

TypeError: unsupported operand type(s) for -: 'list' and 'int'

I have a the following code:

def fib(n): 
    if n < 1: return 1
    return fib(n-1) + fib(n-2)

Where I would put in an array from 1-10000 as n and it would give me an error. May someone help me point out the problem?

Upvotes: 0

Views: 4297

Answers (1)

Deck
Deck

Reputation: 1979

The point of the problem is that you can't pass a list to your function. Your function wants an integer value.

>>> fib(5)
13

As expected. So you should pass just a number (n) to your function to calculate fibonacci of it.

Upvotes: 2

Related Questions