Hey guys, in this blog we will see a Python Program to Check if a Key is Already Present in a dictionary.
Using in keyword
my_dict = {1: 'a', 2: 'b', 3: 'c'}
if 2 in my_dict:
print("present")
Output
present
- Here we are simply checking if key 2 is present in our dictionary or not.
- Note we can check for keys using the following also:
my_dict = {1: 'a', 2: 'b', 3: 'c'}
if 2 in my_dict.keys():
print("present")
Check out our other python programming examples…


![[Latest] Python for Loops with Examples – Easiest Tutorial – 2025](https://machinelearningprojects.net/wp-content/uploads/2023/05/python-for-loops-1-1024x536.webp)


