Python dictionary items() Method
Advertisements
Description
The method items() returns a list of dict's (key, value) tuple pairs
Syntax
Following is the syntax for items() method
dict.items()
Parameters
NA
Return Value
This method returns a list of tuple pairs.
Example
The following example shows the usage of items() method.
#!/usr/bin/python
dict = {'Name': 'Zara', 'Age': 7}
print "Value : %s" % dict.items()
Let us compile and run the above program, this will produce the following result:
Value : [('Age', 7), ('Name', 'Zara')]