Categories

Dec 14, 2019 in Python

Q: What Does The *Args Do In Python?

1 Answer

Dec 14, 2019
We use *args as a parameter in the function header. It gives us the ability to pass N (variable) number of arguments.

Please note that this type of argument syntax doesn’t allow passing a named argument to the function.

Example of using the *args:

# Python code to demonstrate

# *args for dynamic arguments

def fn(*argList):  

    for argx in argList:  

        print (argx)

    

fn('I', 'am', 'Learning', 'Python')

The output:

I

am

Learning

Python
Click here to read more about Python
Click here to read more about Insurance

Related questions

Madanswer
Aug 30 in Python
Dec 22, 2019 in Python
Dec 14, 2019 in Python
...