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'