Python : function : Multiple Returns

Hello,

I have an question from codecademy

I wonder why the first one is never working but the second is…

could you please explain this?

Thanks,

Jinny

Because a function call func() is designed to return something; it is not something that can be assigned to. More generally in an assignment for example x = f(y) you would be evaluating f(y) and assigning the outcome to the name x. The value of x does not matter and it does not affect the right hand side. Always remember that the right side is evaluated and the left is assigned to.

1 Like