Aug 29 in Python
Q: Can you please help to clarify what does the *args do in Python Language?

1 Answer

Aug 29
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 Language code to demonstrate

# *args for dynamic arguments

def fn(*argList):  

    for argx in argList:  

        print (argx)


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

The output:




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

Related questions

Aug 29 in Python
Aug 29 in Python
Aug 30 in Python