I'm learning Python and I was writting this snippet:
def some_function(a):
if a <= 5:
return b = a + 5
elif a > 5:
return b = a + 20
When i run it, it appears :
return b = a + 5
^
SyntaxError: invalid syntax
However, if i write it in this way, it works:
def some_function(a):
if a <= 5:
b = a + 5
elif a > 5:
b = a + 20
return b
Why does it works this way?