12 August 2020   |   by Jatin Jeena   |   React, Blogs

*args & **kwargs in Python

*args and **kwargs in Python





What are *args and **kwargs?

*args and **kwargs are special symbols used in python for passing variable number of arguments to a function.




*args

We can use a symbol * before the parameter name to receive the variable number of arguments.
Using * before the name of the parameter makes it iterable.
Using * before the name of the parameter makes it iterable.




Output
**kwargs

We use **kwargs to pass a variable length keyword arguments.*args cannot be used for the same.
We just neend to place ** before the name of the argument to denote this type of argument.
In this the arguments are passed as dictionary.




Output