0 votes
1 view
in Python by (47.8k 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 (107k 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))

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 !


Categories

...