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
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
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