str1 = " Starbucks has the best coffee " newstr = str1.strip() or for sub in list1: rez.append(sub.replace(" ", ""))