def match_us_state(state_string):
if state_string:<EOL><INDENT>state_string = state_string.upper().replace('<STR_LIT:.>', '<STR_LIT>').strip()<EOL>if us_state_to_iso_code.get(state_string):<EOL><INDENT>return us_state_to_iso_code.get(state_string)<EOL><DEDENT>else:<EOL><INDENT>for code, state_spellings in us_states_alternative_spellings.items():<EOL><INDENT>for spelling in state_spellings:<EOL><INDENT>if state_string == spelling:<EOL><INDENT>return code<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>return None<EOL>
Try to match a string with one of the states in the US.