if key in dictionary has string 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 contains key
if key in dictionary:
print(True)
dict = {"key1": 1, "key2": 2}
if "key1" in dict:
if key in dictionary:
print(True)