Python Dictionary items

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

dictionary_name.items()

Python Dictionary items Example

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

TIP: Please refer to the Dictionary in Python.

# Python Dictionary items Example

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

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

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

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