list comprehension for extraction operation in above sectioni if statement with loopis very commontherefore python provide way to do it in one linewhich is known as 'list comprehension'as shown belowfrom datamine import read_file ring_data read_file('price csv'small_ring [small_ring [(ring['metal']ring['radius']ring['price']for ring in ring_data if ring['radius' for ring in small_ringprint(ring('copper' ('iron' lambda operator in numref:data_in_dictthe data was saved in the dictionary and then specific type of data is extraced in above setion in this sectionwe will sort the data store in the dictionary basis method for sorting let' do it in the python shell as shown below first see the content of the dictionary againfrom datamine import read_file ring_data read_file('price csv'for data in ring_dataprint(data{'date''''metal''gold''radius' 'price' 'quantity' {'date''''metal''silver''radius' 'price' 'quantity' {'date''''metal''iron''radius' 'price' 'quantity' {'date''''metal''gold''radius' 'price' 'quantity' {'date''''metal''copper''radius' 'price' 'quantity' {'date''''metal''iron''radius' 'price' 'quantity' note thatunlike listwe can not perform the sort(operation on dictionary we will have following errorring_data sort(traceback (most recent call last)file ""line in typeerror'<not supported between instances of 'dictand 'dictto sort the data in dictionarywe need to provide 'keyto the sort(method the key can be extracted from the dictionary using function then this function should be called using sort(method as shown below list comprehension