import string
s = "Salut\n\tComment ca va ?"
t = str.maketrans("\n"," ")
y = str.maketrans("\t"," ")
#z = str.maketrans("\n\t"," ")
s = s.translate(t).translate(y)
My Out > 'Salut Comment ca va ?'
Expected > 'Salut Comment ca va ?' # only one space after the Salut
After maketrans we need to give space, why cant we give a null
Disclaimer I can use replace and regex for this but that is not the case
#with replace
s.replace('\n', '').replace('\t','')
#with regex
regex = re.compile(r'[\n\t]')
regex.sub("", s)