EN
Python - check if dictionary key exists
3
points
In this article, we would like to show you how to check if dictionary key exists in Python.
Practical example
Below example presents how to check if the dictionary contains specified key using in
keyword.
my_dict = {
"id": 1,
"name": "Tom",
"age": 25
}
if "age" in my_dict:
print("True")
else:
print("False")
Output:
True