TypeError:unhashable type: 'list'
Hi Every one, I just started the python course and would like to make a table containing the "unique cities USA" from the given .csv file. I want the table to contain the STATE_NAME, unique cities, etc. I wrote the loop down, but when i Run it, it came the "TypeError:unhashable type: 'list'" highlighting the " return set(columns)". Can any one help me, please? import csv def unique_cities_USA(input_csv_file,top,header_name): f=open(r'H:\paython\USCounties.csv','r') reader =csv.reader(f) header = next(reader) print(header) header_var = header.index(header_name) rows=[] while(reader.line_num<top): rows.append(next(reader)) columns=[] for row in rows: columns.append(rows[header_var]) f.close() return set(columns) csv_path = r"H:\paython\USCounties.csv" print (unique_cities_USA(input_csv_file =csv_path,top=100,header_name='STATE_NAME'))