Latest web development tutorials

Python dictionary (Dictionary) items () method

description

Python dictionary (Dictionary) items () function can return a list traversal (key, value) tuples array.

grammar

items () method syntax:

dict.items()

parameter

  • NA.

return value

Returns traversal (key, value) tuples array.

Examples

The following example shows the items () method using the function:

#!/usr/bin/python

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

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

The above example output is:

Value : [('Age', 7), ('Name', 'Zara')]