Args and kwargs

you said that if we print args like this:

def fun(*args)
print (args)

o/p will be in a single tuple like
(1,2,3,4)

and if we use
print(*args)

o/p will be individual elements like
1 ,2 ,3, 4

why is it not the same with kwargs
why is it giving error

hey @ayushU2x ,
if we make a function that accepts both args and kwargs .
like for example
def fun(*args,**kwargs)

on calling this function like
fun(1,1,2,2,sum=12,work=10)

so , on calling this function like this,
then args would become a list with values as ( 1,1,2,2 ) ( all non-keyword arguments )
and kwargs would be a dictionary {'sum':12,'work':10} ( all keyword arguments )

so , when printing with * , it prints the tuple , but it doesn’t work on dictionary and then it doesn’t works and results in an error.
I hope you understand this.
Thank You and Happy Learning :slight_smile:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.