state_slugs = {}
states_from_slugs = {}
for state_name, state_code in list(state_dict.items()):
    slug = state_name.lower().replace(' ', '_')
state_slugs[state_name] = slug
state_slugs[state_code] = slug
states_from_slugs[slug] = state_name
Dealing with spaces in Flask url creation