What are *args and **kwargs?

Python control flow and functions · Freshers and experienced

Model answer

*args collects extra positional arguments into a tuple. **kwargs collects extra keyword arguments into a dictionary. They let a function accept a flexible number of arguments, and the same symbols unpack a list or dict when calling: f(*args, **kwargs).

Learn this topic

Functions in Python: def, Arguments and return in the course Python for Beginners: Learn to Code with Real Projects.

Sign in to add your own answer.

More questions