The has_key method checks whether a dictionary has a given key. : has_key « Dictionary « Python Tutorial






d = {'name':'Joe'}
print d.has_key('name')
d['name'] = 'Eric'
print d.has_key('name')








8.11.has_key
8.11.1.The has_key method checks whether a dictionary has a given key.
8.11.2.The Boolean has_key() and the in and not in operators are Boolean, returning True if a dictionary has that key and False otherwise.