Question: IN PYTHON Write a function named loadStateDict(filename) that takes a filename and returns a dictionary of 2-character state codes and state names. The file has

IN PYTHON

Write a function named "loadStateDict(filename) that takes a filename and returns a dictionary of 2-character state codes and state names. The file has four columns and they are separated by commas. The first column is the state full name and the second column is the state code. You don't have to worry about column 3 & 4. You should eliminate any row that is without a state code. Save the two columns into a dictionary with key = state code and value = state name. Return a dictionary at the end of the function.

d = { "AL" : "Alabama", "AK": "Alaska", ... } 

Sample code:

filename = input('Enter state code file name: ') stateDic = loadStateDict(filename ) 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!