I am working on some Homework and the assignment call for us to open a CSV and pull the info out into columns with fixed widths. Afterwards we need to filter the info with after a user inputs a selection. and this is where I am stuck. I cant seem to get the list of states to filter after the user select. Any help would be great the assignment is due on Sunday and I have been working on it all week thanks to this forum and many other I am were I am now.
import csv def Location(State): State = state if (State in state): return True else: return False titleLocation = "Location" titleDisease = "Disease" titleNumber = "Number" titleYear = "Year" print("%-25s %-15s %-15s %-15s" %(titleLocation, titleDisease, titleNumber, titleYear)) total = 0 with open("health-no-head-sample.csv", "r") as health: file_reader = csv.reader(health) for aline in file_reader: total += float(aline[3]) number = aline[3] state = aline[2] disease = aline[0] year = aline[5] print("%-25s %-15s %-15s %-15s" %(state, disease, number, year)) print("%-25s %-15s %-15s" %('', 'Total', total)) State = input('Select a state ') if State == state: filtered = filter(Location, state) for state in filtered: print(state)