+def stand_strings( str_list, delim ):
+ """Standardize capitalization and word delimiters for a list of strings.
+ str_list (list): A list of of input strings.
+ delim (char): The desired output word delimiter - must be one of
+ ' ' (i.e. space), '-', '_', or '.'
+ List of input strings, converted to uppercase with word delimiters
+ converted to the user's chosen delimiter.
+ >>>ny = [' New York City ', 'New-York_City', 'new.york.city']
+ >>>print(stand_strings(ny, "_"))
+ ['NEW_YORK_CITY', 'NEW_YORK_CITY', 'NEW_YORK_CITY']
+ ## Check for appropriate word delimiter selection
+ if delim not in [' ', '-', '_', '.']:
+ sys.exit('''Please select one of the following for the output word delimiter:
+ " " (space), "-", "_", "." ''')
+ ## Convert to uppercase, strip leading/trailing whitespace
+ str_list = [x.upper().strip() for x in str_list]
+ ## Swap out whitespace, dash, period, underscore for selected delimiter
+ str_list = [re.sub('\s|\.|-|_', delim, x) for x in str_list]