remove string punctuation python 3

Solutions on MaxInterview for remove string punctuation python 3 by the best coders in the world

showing results for - "remove string punctuation python 3"
Kris
26 May 2018
1import string
2#make translator object
3translator=str.maketrans('','',string.punctuation)
4string_name=string_name.translate(translator)
Rania
20 Sep 2018
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