0
def fib(n):
    if n == 0 or n == 1:
        return n
    else:
        return fib(n–1)+fib(n–2)

I saw the code in the book, but this code has a bug below, SyntaxError: invalid character in identifier

Could you please help me about this?

1 Answers1

0

return fib(n–1)+fib(n–2) is wrong because of your symbol which is not a valid ASCII minus character

SyntaxError: Non-ASCII character '\xe2' in file main.py on line 5, but no encoding declared;

Your is a \xe2 character.

Replace it by a normal minus and it'll work

def fib(n):
    if n == 0 or n == 1:
        return n
    else:
        return fib(n-1)+fib(n-2)
Hearner
  • 2,711
  • 3
  • 17
  • 34