- items() is a python dictionary function which gets the all items in the dictionary and make a pair of each keys and their corresponding values.
Syntax-
dictionary.items()
Example
dictionary is {1:"one",2:"two"}
then items() return a pair like [(1:"one"),(2:"two")]
program-
d={1:None,2:None,3:None}
print("Enter value of key 1")
d[1]=input()
print("Enter value of key 2")
d[2]=input()
print("Enter value of key 3")
d[3]=input()
print(d.items())
Enter value of key 1
one
Enter value of key 2
two
Enter value of key 3
three
dict_items([(1, 'one'), (2, 'two'), (3, 'three')])