check for dictionary with key in list code example
Example 1: how to know if a key is in a dictionary python
dict = {"key1": 1, "key2": 2}
if "key1" in dict:
Example 2: python test if list of dicts has key
>>> lod = [{1: "a"}, {2: "b"}]
>>> any(1 in d for d in lod)
True
>>> any(3 in d for d in lod)
False