Analytics Vidhya
Published in

Analytics Vidhya

*args and **kwargs in Python

args and kwargs

*args in Python

The function which takes 2 arguments and returns their product
Passing a list of number to a function1
mul_nums function using *args

**kwargs in Python

mul_nums function using **kwargs
Iterating through kwargs without values method
Iterating through kwargs.items

Ordering Arguments

  1. Standard arguments
  2. Positional arguments(*args)
  3. Keyword arguments(**kwargs)
ordering arguments


  1. *args and **kwargs are very handy while passing a variable number of arguments to a function.
  2. *args are used to pass positional arguments.
  3. **kwargs are used to pass keyword arguments
  4. While passing different types of arguments the order should be Standard arguments, Positional arguments(*args), and Keyword arguments(**kwargs).



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store