Languages
[Edit]
EN

Python - check if dictionary key exists

3 points
Created by:
Nicola-Melendez
375

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
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join