Write a python function to check if a key exists in a dictionary


Topic: Write a python function to check if a key exists in a dictionary

Solution

d = {'key1': 'value1', 'key2': 'value2', 'key3': 'value3', 'key4': 'value4'}
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')



List all Python Programs