programming-examples/python/Dictionary/Python program to check if a given key already exists in a dictionary.py
2019-11-15 12:59:38 +01:00

8 lines
249 B
Python

d = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
def is_key_present(x):
if x in d:
print('Key is present in the dictionary')
else:
print('Key is not present in the dictionary')
is_key_present(5)
is_key_present(9)