in Python by
Q:
Can you please help to clarify what does the **kwargs do in Python Language?

1 Answer

0 votes
by
We can also use the **kwargs syntax in a Python Language function declaration. It let us pass N (variable) number of arguments which can be named or keyworded.

Example of using the **kwargs:

# Python Language code to demonstrate

# **kwargs for dynamic + named arguments

def fn(**kwargs):  

    for emp, age in kwargs.items():

        print ("%s's age is %s." %(emp, age))

    

fn(John=25, Kalley=22, Tom=32)

The output:

John's age is 25.

Kalley's age is 22.

Tom's age is 32.
Click here to read more about Python
Click here to read more about Insurance

Related questions

0 votes
asked Aug 30, 2020 in Python by sharadyadav1986
0 votes
asked Aug 29, 2020 in Python by Robindeniel
0 votes
asked Aug 30, 2020 in Python by sharadyadav1986
0 votes
asked Aug 29, 2020 in Python by Robindeniel
0 votes
asked Aug 29, 2020 in Python by Robindeniel
...