This class method return true if a given key is available in the dictionary otherwise it returns a false.
dict.has_key(key)
Here is the detail of parameters:
key: Key to be searched in the dictionary.
#!/usr/bin/python dict = {'Name': 'Zara', 'Age': 7} print "Value : %s" % dict.has_key('Age') print "Value : %s" % dict.has_key('Sex')
This produces following result:
Value : True Value : False
Advertisement