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?
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?
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)