Using *args and **kwargs for Flexible Function Arguments in Python


Accept an arbitrary number of arguments and keyword arguments in functions.

Source Code

def my_func(*args, **kwargs):
    print(args)
    print(kwargs)
my_func(1, 2, 3, name="John", age=30)
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments