12. On Beyond Strings


#1




Just a question about the code. Why is the argument for biggest_number (*args) ?

Thank you.


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)
distance_from_zero(-10)


#2

splat


#3

TY. I will just stackoverflow from now on:

You would use *args when you're not sure how many arguments might be passed to your function, i.e. it allows you pass an arbitrary number of arguments to your function.


#4

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