Launch offer
Business website $150 USD Custom plugin $200 USD Ready in 5 days
Get a quote
Python

*args and **kwargs in Python

Accept flexible positional and keyword arguments with *args and **kwargs.

*args and **kwargs in Python — a practical guide to Python args kwargs with clear examples you can reuse in real projects.

Python Tutorial Series (29/95). Prefer one article? Read the complete Python tutorial.

Short description

`*args` collects extra positional values into a tuple. `**kwargs` collects keyword args into a dict.

Flexible signature

def demo(*args, **kwargs):
    print(args)
    print(kwargs)

demo(1, 2, 3, city='Surat', ok=True)

Leave a reply

Your email address will not be published. Required fields are marked *