Latest web development tutorials

Python dictionary (Dictionary) len () method

description

Python dictionary (Dictionary) len Total () function calculates the number of elements in the dictionary, that is the key.

grammar

len () method syntax:

len(dict)

parameter

  • dict - To calculate the number of elements in the dictionary.

return value

Returns the number of elements in the dictionary.

Examples

The following example shows len () function to use:

#!/usr/bin/python

dict = {'Name': 'Zara', 'Age': 7};
print "Length : %d" % len (dict)

The above example output is:

Length : 2