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

javascript - Can Piwik report referrer in real time? -

asp.net - Google Drive Access: At least one client secrets (Installed or Web) should be set -

c# - How do I debug "System.DllNotFoundException: The specified procedure could not be found"? -