#This is code to remove "," and "'" in code #importing regex module import re #Final Storage array final_name = [] #Defining our regex that will remove commas(,) and apostrophes('), however it will ignore spaces #This is a test / example code, replace with your own names = ["Cow","Chick'en", "Crick,et", "Bu'll", "She,e,p"] #The regex pattern2 = re.compile(r'[^a-zA-Z0-9\s]+') #Looping over the values in the names list to remove the characters and substitute them. for name in names: result3 = pattern2.sub("", name) final_name.append(result3) print(final_name)