I have a function:
def myfunc():
kwargs = {}
a = 1
b = 2
kwargs.update(a=a, b=b)
newfunc(**kwargs)
and my newfunc
def newfunc(**kwargs):
print a
Its not giving the value of a which is 1
whats wrong ?
It's because you didn't put any key, value in your dictionary, you should have written that :
def newfunc(**kwargs):
print kwargs["a"]
def myfunc():
kwargs = {"a" :1, "b": 2}
newfunc(**kwargs)
You can refer to this thread to understand kwargs better : Understanding kwargs in Python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With