Completely new to python and wondering how i can do this problem with multidimensiona l dictionaries. problem is to go in some file which has a counties information on a line with its state as well.
the objective is to prompt for a state and the program tells you which of the counties has the most (not necessary for me to explain) of one of the details. what i want to do is create a dictionary that takes as key the state and as value a dictionary(call ed state_dict). Then i want state dict to take county name as key and to take another dictionary as value(county_di ct). and then county_dict to take 4 keys of info and their values as their appropriate values.
what i have so far is
the objective is to prompt for a state and the program tells you which of the counties has the most (not necessary for me to explain) of one of the details. what i want to do is create a dictionary that takes as key the state and as value a dictionary(call ed state_dict). Then i want state dict to take county name as key and to take another dictionary as value(county_di ct). and then county_dict to take 4 keys of info and their values as their appropriate values.
what i have so far is
Code:
state=[]
usa_dict = {}
state_dict = {}
county_dict = {}
data = open("est10ALL.txt","rU")
for line in data:
line=line.strip()
line=line.split()
state.append(line)
if line[-3] not in usa_dict:
usa_dict[line[-3]]= state_dict
if line[-5] not in state_dict:
state_dict[line[-5]] = county_dict
Comment