We’ve already seen some functions that accept a variable number of arguments like print() or zip(). Yet, we haven’t created one ourselves. How to write a function that can handle a variable number of arguments?
When printing elements, we can call the print() function with as many arguments as we want and it will print all of them:
print('Hi') # Hi
print('Hi', 'how', 'are', 1) # Hi how are 1
print(1, 2, 3, 8) # 1 2 3 8
If we take a look at the function signature of print() in the official python docs, the first argument actually captures the whole list of arguments (non-keyword) passed to it. The same holds for the zip function: