How to Pass Variable Number of Arguments in Python


In this example we will show how to deal with when the number of function arguments is unknown in Python.

Source Code

def my_function(*num):
    print(num[2] + num[4])

my_function(1, 6, 7, 10, 20)

Output:

27
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments