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
Post a Comment