Before We Begin - return True


In the first part of Taking a Vacation, Before We Begin, why does the example function return True?

def bigger(first, second):
print max(first, second)
return True


It’s likely that author wanted to demonstrate return. There is no practical reason other than that.

Try the code in your lesson space, calling it with a print statement…

print (bigger(42, 24))


Thanks mtf. I put in the function into IDLE and printed the result of calling the function, and the result was:


I also tried removing the return part from the function and the result was:


So a function always needs to return some sort of value?


Function calls are expressions and expressions evaluate to values, so yes, there has to be a result when calling a function. If you do not explicitly specify a value, None will be returned (representing lack of value)


Thank you for clearing that up ionatan. Seems to be a fundamental concept. I will keep this in mind as I continue. Much appreciated.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.