Function Arguments: *args and **kwargs in Python


Pass a variable number of arguments to a function.

Source Code

def my_func(*args, **kwargs):
    print(args)  # Tuple of positional arguments
    print(kwargs)  # Dictionary of keyword arguments

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