This returnsis the control flow of the calling function. It also returnsoutputs / outputs to the calling function.
Consider the function below:
def am_i_wrong(answer):
if answer == 'yes':
return True
else:
return False
You have several returns. Thus, it returndoes not just end the function definition. Instead, this is the point at which the function returns the result to the caller.
If answer“yes”, then nothing after the if statement (after if and else) never starts because the function has already been returned.