What are *args and **kwargs in Python?

The syntax is the * and **, the names *args and **kwargs are only by convention and you can use any other words (not keyword) in place of args and kwargs.

You would use *args when you’re not sure how many arguments might be passed to your function, i.e. it allows you to pass an arbitrary number of arguments to your function. For example:

Similarly, **kwargs allows you to handle named arguments that you have not defined in advance: