The best way to remove punctuation from a string in Python would be using regular expressions see the code below:-
import re s = "string. With. Punctuation?"
s = re.sub(r'[^\w\s]','',s)
In the above code we are substituting(re.sub) all NON[alphanumeric characters(\w) and spaces(\s)] with an empty string.
So, the ‘ .’ and ‘?’ punctuation won't be present in variable 's' after runnings variable through the regex.
To know more about this you can have a look at the following video tutorial:-