#!/usr/bin/env python #------------------------------------------------------------------------------- # Name: process_string(string) # Purpose: Takes a single string, strips the newline characters and removes # punctuation, splits it into a list of words, and returns the list # # Author: Christopher Conly # # Created: 08/01/2012 # Copyright: (c) Christopher Conly 2012 # # CSE 1310 - University of Texas at Arlington #------------------------------------------------------------------------------- import string as s import sys def process_string(string): if type(string) != str: print 'Argument type error. The argument must be a string.' return None try: words = [] string = string.strip('\r\n\ ') words += string.split() # Remove the punctuation for i in range(len(words)): words[i] = words[i].translate(s.maketrans('',''), s.punctuation) return words except: print 'Error processing string.' return None