Functions are a control structure. When they are called, they change the order of statements that are executed. They always return to the statement from which they were called.

All control structures have the guarantee that they have ONE entrance and ONE exit. This takes a little thought with functions, especially functions which return Bool values. It is natural to think in terms of :

      def fun1 (a, b):
         if a > b: 
             return False
         else:
             return True

But this code has TWO exits from the function. Both return statements can be executed, at one time or another. This breaks the guarantee of structured programming.

How this function should be written to maintain the guarantee:

      def fun1 (a, b):
         if a > b: 
             retval = False
         else:
             retval = True
         return retval

"retval" is not anything special in Python, just stands for "return value".

This code has ONE exit, at the bottom of the function definition. This makes functions easier to understand and to debug. When you have a single variable that is holding the result of the function as it processes through its statements, you can see what the value is in a debugger, for example. Return values of functions are sometimes not displayed clearly, and not until the return has taken place.

Please follow this model. Each function should have (at most) ONE return statement, at the bottom of the function definition. Why "at most"? Of course some functions do not have a return value, so they don't need a return statement.