The inbuilt items()
method in Python is used to return a view object, which contains the key-value pairs of a dictionary. These key-value pairs will be returned as tuples in a list.
A view-object gives a dynamic view of the dictionary. Whenever the dictionary is altered, the view-object will mirror those alterations.
dictionary.items()
This method does not require any parameters.
postcodes = {'griffith':2603, 'belconnen':2617, 'phillip':2606}x = postcodes.items()print(x)
#This example represents how the returned#view object is dynamicpostcodes = {'griffith':2603, 'belconnen':2617, 'phillip':2606}x = postcodes.items()postcodes.update({'civic': 2601})print(x)