Using *args and **kwargs in Python


Pass a variable number of arguments to a function.

Source Code

def foo(*args, **kwargs):
    print("args:", args)
    print("kwargs:", kwargs)

foo(1, 2, three=3, four=4)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments