Check if Key Value Pair Exists in Dictionary Python Example

By Hardik Savani October 30, 2023 Category : Python


This tutorial will provide an example of how to check if key value exists in dictionary python. I’m going to show you about check if key value exists in dictionary python. This post will give you a simple example of check if value exists in nested dictionary python. In this article, we will implement a python dictionary check if key value exists.

There are several ways to check key value pair is exists or not in dictionary in python. we will use items() function to check key/value pair in python dictionary.

So, without further ado, let's see simple examples:


user = {
  "ID": 1,
  "name": "Hardik",
  "email": ""
# Check value is present in dictionary
if ("name", "Hardik") in user.items():
    print("key value pair is exists.")
    print("key value pair is not exists.")


key value pair is exists.

I hope it can help you...

Tags :