- In solution 1, we join all the words, separating them by a space.
a = " ".join(words)- Then we exchanged '.' By '' and we use split () to separate the string into different words by spaces.
return a.replace(separator," ").split()- In solution 2, for each word, we apply split (), and if the result is not empty, we add to the answer.
for i in word.split(separator):
if i: # Check if the split word is not empty.
ans.append(i)