I know how to check if I key in **kwargs exists. Now I want to check the value of an argument passed to a function.
def examplefunc(x,y,**kwargs):
print(kwargs['extraarg'])
if 'extraarg' in kwargs == True:
print(kwargs['extraarg'])
print("This is not printed")
if 'extraarg' in kwargs: print("This is printed")
examplefunc(3,2,extraarg=True)
Output:
True
This is printed
Why isn't This is not printed
printed? 'extraarg' in kwargs
is false. So why is it proceeding to print This is printed
?
I also tried to replace the line if 'extraarg' in kwargs == True
with if 'extraarg' == True:
, but the output still lacks This is not printed
.