(continued from previous page('''gold' for data in ring_dataprint metal with radius if data[ print("metal{ }radius{ }format(data[ ]data[ ])metalsilverradius metalironradius `data_in_dict`save and read data in dictionary in the previous sectionthe list is read and data is printed ( name of metal when radius it worked fine therebut when we have large number of columns in the listthen it is very difficult to locate the elements using positions 'data[ ]for easy referencinga dictionary can be used as shown below note thatat line the elements are located by the namei row['price']which is easier to handle than using index row[ datamine py import csv def read_file(filenamemode='warn')''read csv file and save data in the list ''check for correct mode if mode not in ['warn''silent''stop']raise valueerror("possible modes are 'warn''silent''stop'"ring_data [create empty list to save data with open (filename' 'as frows csv reader(fheader next(rowsskip the header change the types of the columns for row in rowstryrow[ float(row[ ]radius row[ float(row[ ]price row[ int(row[ ]quantity except valueerror as errprocess value error only if mode ='warn'print("invalid datarow is skipped"print('row{}reason {}format(row_numerr)elif mode ='silent'pass do nothing elif mode ='stop'raise raise the exception continue ring_data append(tuple(row)append data in list in the form of tuple row_dict 'daterow[ ](continues on next page building data structure from file