We can check it with “in” operator and “get()” method
In operator here returns the value True or False
For example
dictionary={"one":1, "two":2}
if "two" in dictionary:
print("two exist in the dictionary")
The get() method returns the value if that key exists. If not exists it returns None
dictionary_data={"one":1, "two":2}
#Here the key three is not in the dictionary data so it will return None
key_value=dictionary_data.get("three")
print(key_value)
if key_value is not None:
#As it returns None so it will not print anything
print(key_value)
print("=============================")
# Two is in the dictionary data so it will return the value
key_value=dictionary_data.get("two")
print(key_value)
if key_value is not None:
print(key_value)