It is just this:
if 'errormessage' in kwargs:
print("yeah it's here")
You need to check, if the key is in the dictionary. The syntax for that is some_key in some_dict
(where some_key
is something hashable, not necessarily a string).
The ideas you have linked (these ideas) contained examples for checking if specific key existed in dictionaries returned by locals()
and globals()
. Your example is similar, because you are checking existence of specific key in kwargs
dictionary (the dictionary containing keyword arguments).