Home>

I have a question about Python. What happens if * (asterisk) is added to the first line in the following cases? Asterisk too
I don't understand because it has various meanings. First line* argsis.

def get_max_min (* args):
    return (max (args), min (args))
max_v, min_v = get_max_min (15, 7.5, 108, -10)
print (max_v) # 108
print (min_v) # -10


I looked it up in a book, but there were several types, but I don't know what they mean. Attached to the function argument
I understand only that. If i am familiar with Python, please let me know.

  • Answer # 1

    Variadic argument.

    >>>def func (* args):
    ... print (args)
    ...
    >>>func (1, 2)
    (1, 2)
    >>>func ('spam','ham','egg')
    ('spam','ham','egg')