On Beyond Strings


Just a query about following code.
Why we are using return statement, "return max(args)"

In the following code, when I put a comment on return statement, there was no difference in the output


Replace this line with your code. 
def biggest_number(*args):
    print max(args)
    #return max(args)
def smallest_number(*args):
    print min(args)
    #return min(args)

def distance_from_zero(arg):
    print abs(arg)
    return abs(arg)

biggest_number(-10, -5, 5, 10)
smallest_number(-10, -5, 5, 10)


They work because you are printing inside the functions. The ones with no return are returning None.


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