I use code to extract a line of text from punctuation:
line = line.rstrip("\n") line = line.translate(None, string.punctuation)
The problem is that words like doesn't appeal to doesnt , so now I want to remove punctuation only between words, but I canβt figure out how to do this. How should I go about it?
Edit: I was thinking about using the strip() function, but this will only affect the right and left trailing of the entire sentence.
For instance:
Isn't ., stackoverflow the - best ?
It should become:
Isn't stackoverflow the best
Instead of the current output:
Isnt stackoverflow the best
source share