Python Dictionary items

Python items function returns the list of available dictionary items (total keys and values). In this section, we discuss the use of this Dictionary items function and the syntax of it is:

dictionary_name.items()

Python Dictionary items function Example

The items function returns the list of total key-value pairs available in a given dictionary. The below items code prints the key-value pairs in emp and employ.

TIP: Please refer to the Dictionary in Python.

emp = {'name': 'Kevin', 'age': 25 , 'Sal': 725000}
print("Dictionary: ", emp)

# Print Items
print("Items: ", emp.items())

# Creating an Empty 
employ = {}
print("\nDictionary: ", employ)

# Print Values
print("Dictionary Items: ", employ.items())
Python Dictionary items function example 1