1#with re
2import re
3s = "string. With. Punctuation?"
4s = re.sub(r'[^\w\s]','',s)
5#without re
6s = "string. With. Punctuation?"
7s.translate(str.maketrans('', '', string.punctuation))
1import string
2sentence = "Hey guys !, How are 'you' ?"
3no_punc_txt = ""
4for char in sentence:
5 if char not in string.punctuation:
6 no_punc_txt = no_punc_txt + char
7print(no_punc_txt); # Hey guys How are you
8# or:
9no_punc_txt = sentence.translate(sentence.maketrans('', '', string.punctuation))
10print(no_punc_txt); # Hey guys How are you