def preprocess(text): translation_table = str.maketrans('\n', ' ', string.puntuation+string.digits) pre_p_txt = pre_p_txt.translate(translation_table) return pre_p_txt print('pre_p_txt') code example
Example: python3 strip punctuation from string
import string
#make translator object
translator=str.maketrans('','',string.punctuation)
string_name=string_name.translate(translator)