The inbuilt keys()
method in Python is used to return a view object that contains all the keys
of a dictionary 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.
dict.keys()
This method does not require any parameters.
postcodes = {'griffith':2603, 'belconnen':2617, 'phillip':2606}x = postcodes.keys()print(x)
#This example represents how the returned#view object is dynamicpostcodes = {'griffith':2603, 'belconnen':2617, 'phillip':2606}x = postcodes.keys()postcodes.update({'civic': 2601})print(x)