@pythoncodestar
adada.py
3 years
As a beginner in Python programming, I am sure you have heard a lot about *args and **kwargs. So what exactly are they? A thread🧵
1
1
1

Replies

@pythoncodestar
adada.py
3 years
Yes, *args and **kwargs allow for passing an unlimited number of arguments to a function in Python. The special syntax *args in function definitions in Python allows us pass a variable number of non-keyworded arguments to a function. Find an example below.
1
0
0
@pythoncodestar
adada.py
3 years
Similarly, the keyworded **kwargs arguments allows the user to pass a variable number of keyworded arguments to a function. For instance, you can pass a dictionary of arguments to a function and unpack them using **kwargs. Check the example below:
1
0
0
@pythoncodestar
adada.py
3 years
Overall, *args and **kwargs can be incredibly useful when working with functions that take a variable number of arguments. Happy coding! 🚀
0
0
0