Copyright © tutorialspoint.com

Python dictionary has_key() Method

previous next


Description:

This class method return true if a given key is available in the dictionary otherwise it returns a false.

Syntax:

dict.has_key(key)

Parameters:

Here is the detail of parameters:

Example:

#!/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

previous next

Copyright © tutorialspoint.com