Post

Python Dictionary items()

The items() method returns a view object of the dictionary. A view object is the list containing the key-value pairs of the dictionary as tuples inside the list.

Python Dictionary items()

The syntax of items() is:

1
2
dictionary.items()

items() Parameters

The items() method does not take any parameters as arguments.

Let see an example of the items() method in python.

Example 1: How to use items() method in python dictionaries?

1
2
3
4
cars = { 1 : "BMW", 2 : "TOYOTA", 3 : "TATA"}

print(cars.items())

Output:

1
2
dict_items([(1, 'BMW'), (2, 'TOYOTA'), (3, 'TATA')])

Rules of items()

There are no such rules for items().

This post is licensed under CC BY 4.0 by the author.