How to remove punctuation in python?

string.punctuation contains following characters:

‘!”#$%&\'()*+,-./:;<=>?@[\]^_`{|}~’

You can use translate and maketrans functions to map punctuations to empty values (replace)

import string

'AAA? BBB. CCC! DDD.EEE'.translate(str.maketrans('', '', string.punctuation))

Output:

'AAA BBB CCC DDDEEE'

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)