How can I utilize return on the same line as the calculation?

Why can’t we use return in the same line where you calculate the variable age?
If i define the function
def calculate_age(current_year,birth_year)
return age = current_year - birth_year

This return a syntax error message

We cannot return a statement, only an expression.

return current_year - birth_year

Ok. That makes sense. Thank you very much!

1 Like

Amazing… subtle but important difference between a statement and an expression.

1 Like