Python dictionary items() Method


Contents

Description

Python dictionary technique items() revisits a catalog of dict's (key, value) Tuple pairs. In Python Dictionary, items () way is utilized to revisit the list with entire dictionary keys with worth. Parameters: This system takes no parameters. Returns: A vision object that exhibits a list of a provided dictionary's (key, value) tuple pair. Order of such items in the roll may not always be identical.

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()

When we run above program, it produces following result:

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

Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.



Navigation
Tutorial
Tutorial
Tutorial