Return


#1



inside the function "bigger()", it has returned a value--a or b.
so, why do still need "return"s before "bigger()"s in the function "median()" ?


i have tried remove all the "return" in median(a,b,c),but it prints 'None'


def bigger(a,b):
if a > b:
    return a
else:
    return b

def biggest(a,b,c):
    return bigger(a,bigger(b,c))

def median(a,b,c):   
    if a == biggest(a,b,c):
        return bigger(b,c)     #the function "bigger()" above has returned a value,
                               #so, why still need a 'return' before bigger(b,c)?
    elif b == biggest(a,b,c):
        return bigger(a,c)
    else:
        return bigger(a,b)


#2

if you remove the return from the bigger function call, the median function doesn't return anything, resulting in a None


#3

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