If it has a certain key : Dictionary has Key « Dictionary « Python






If it has a certain key

 

D = {'a': 1, 'b': 2, 'c': 3}

D.has_key('f')

if not D.has_key('f'):
    print 'missing'

   
  








Related examples in the same category

1.Key membership test in a dictionaryKey membership test in a dictionary
2.Dictionary key membership test alternativeDictionary key membership test alternative
3.Dictionary has_key methodDictionary has_key method