Javatpoint Logo
Javatpoint Logo

Python Dictionary items() Method

Python item() method returns a new view of the dictionary. This view is collection of key value tuples. This method does not take any parameter and returns empty view if the dictionary is empty. The examples and syntax are given below.

Signature

Parameters

No parameter

Return

It returns a dictionary's view.

Let's see some examples of items() method to understand it's functionality.

Python Dictionary items() Method Example 1

This is a simple example which returns all the items present in the dictionary.

Output:

dict_items([('name', 'rohan'), ('course', 'B.Tech'), ('email', '[email protected]')])

Python Dictionary items() Method Example 2

If the dictionary is already empty, this method does not raise any error. See the example below.

Output:

dict_items([])

Python Dictionary items() Method Example 3

Apart from items() method, we can also use other customized approaches to fetch dictionary elements. See an example below.

Output:

( name : rohan), ( course : B.Tech), ( email : [email protected]), 
 dict_items([('name', 'rohan'), ('course', 'B.Tech'), ('email', '[email protected]')])

Next TopicPython Dictionary





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA