Python items Dictionary is one of a Dictionary function, used to return the list of available dictionary items (total keys and values). In this section, we discuss how to use this Python Dictionary items function with practical examples.
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 code prints the key-value pairs in emp and employ.
TIP: Please refer to the Dictionary to understand Python Dictionaries.
# 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())
OUTPUT