check if there a value in dictionary python 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 dictionary get value if key exists
val = dict.get(key , defVal) # defVal is a default value if key does not exist