Skip to content

Instantly share code, notes, and snippets.

@jintolonappan
Last active March 5, 2024 08:15
Show Gist options
  • Save jintolonappan/79943c3a20562de8f76ac60eb1b1dd89 to your computer and use it in GitHub Desktop.
Save jintolonappan/79943c3a20562de8f76ac60eb1b1dd89 to your computer and use it in GitHub Desktop.
Python dictionary to convert US States and Territory codes to their names
# Datasource: Wikipedia (https://en.wikipedia.org/wiki/List_of_states_and_territories_of_the_United_States)
us_states_territories = {
'AL': 'Alabama',
'AK': 'Alaska',
'AZ': 'Arizona',
'AR': 'Arkansas',
'CA': 'California',
'CO': 'Colorado',
'CT': 'Connecticut',
'DE': 'Delaware',
'FL': 'Florida',
'GA': 'Georgia',
'HI': 'Hawaii',
'ID': 'Idaho',
'IL': 'Illinois',
'IN': 'Indiana',
'IA': 'Iowa',
'KS': 'Kansas',
'KY': 'Kentucky',
'LA': 'Louisiana',
'ME': 'Maine',
'MD': 'Maryland',
'MA': 'Massachusetts',
'MI': 'Michigan',
'MN': 'Minnesota',
'MS': 'Mississippi',
'MO': 'Missouri',
'MT': 'Montana',
'NE': 'Nebraska',
'NV': 'Nevada',
'NH': 'New Hampshire',
'NJ': 'New Jersey',
'NM': 'New Mexico',
'NY': 'New York',
'NC': 'North Carolina',
'ND': 'North Dakota',
'OH': 'Ohio',
'OK': 'Oklahoma',
'OR': 'Oregon',
'PA': 'Pennsylvania',
'RI': 'Rhode Island',
'SC': 'South Carolina',
'SD': 'South Dakota',
'TN': 'Tennessee',
'TX': 'Texas',
'UT': 'Utah',
'VT': 'Vermont',
'VA': 'Virginia',
'WA': 'Washington',
'WV': 'West Virginia',
'WI': 'Wisconsin',
'WY': 'Wyoming',
'AS': 'American Samoa',
'GU': 'Guam',
'MP': 'Northern Mariana Islands',
'PR': 'Puerto Rico',
'VI': 'U.S. Virgin Islands',
'DC': 'District of Columbia'
}
if __name__ == "__main__":
print(us_states_territories['AZ']) # Arizona
print(f'Total Entries = {len(us_states_territories)}') # Total Entries = 56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment