Asked • 05/25/19

Use of *args and **kwargs?

So I have difficulty with the concept of `*args` and `**kwargs`.So far I have learned that: * `*args` = list of arguments - as positional arguments * `**kwargs` = dictionary - whose keys become separate keyword arguments and the values become values of these arguments.I don't understand what programming task this would be helpful for. Maybe:I think to enter lists and dictionaries as arguments of a function AND at the same time as a wildcard, so I can pass ANY argument?Is there a simple example to explain how `*args` and `**kwargs` are used?Also the tutorial I found used just the "*" and a variable name. Are `*args` and `**kwargs` just placeholders or do you use exactly `*args` and `**kwargs` in the code?

1 Expert Answer

By:

Nima M. answered • 11/16/19

Tutor
5 (20)

Python / Java: Object-oriented design, algorithm, data structure

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.