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

mysql - FireDac error 314 - but DLLs are in program directory -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -

android - Change screen orientation in a Unity Google Cardboard project -