Latest web development tutorials

Python dictionary (Dictionary) keys () method

description

Python dictionary (Dictionary) keys () function to return a list of all the keys of a dictionary.

grammar

keys () method syntax:

dict.keys()

parameter

  • NA.

return value

Returns a dictionary of all the key.

Examples

The following example shows the keys () function to use:

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7}

print "Value : %s" %  dict.keys()

The above example output is:

Value : ['Age', 'Name']