Python check if string contains dictionary key -


i have these strings:

>>> a="foo" >>> b="foo_key" 

and dictionary like:

>>> dict { 'key': ['...'], 'key2': ['...', '...'], ... } 

i'd build function check if test value in key of input dict:

>>> has_key(a, dict) false >>> has_key(b, dict) true 

what elegant way task in python 3?

has_key = lambda a, d: any(k in k in d) 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -