Tutorials Point


  Python Basics
  Python Advanced
  Python Useful References
  Python Useful Resources
  Selected Reading

© 2011 TutorialsPoint.COM


  Home     References     Discussion Forums     About TP  

Python dictionary has_key() Method


previous next AddThis Social Bookmark Button


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:

  • key: Key to be searched in the dictionary.

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 Printer Friendly



  

Advertisement

Online Image Processing

Indian Baby Names