*args
and **kwargs
*args
is responsible for passing all arguments and storing them as a tuple.
**kwarg
passes all keyword arguments and stores them as a dict
Little code snippet:
# *args example
def fun(*args):
return sum(args)
print(fun(5, 10, 15))
# **kwargs example
def fun(**kwargs):
for k, val in kwargs.items():
print(k, val)
fun(a=1, b=2, c=3)
Output:
30
a 1
b 2
c 3