Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
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.

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.6k users

Browse Categories