Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

In a similar way to using varargs in C or C++:

fn(a, b)

fn(a, b, c, d, ...)

1 Answer

0 votes
by (106k points)

Yes, a variable number of arguments can be passed to a function it is very simple and works if you disregard keyword arguments below is the code that shows:

def manyArgs(*arg):

print("I was called with", len(arg), "arguments:", arg)


print(manyArgs(1, 2,3))

For keyword arguments in Python, you need to accept those as a separate actual argument, as shown in.

Browse Categories