Используйте метод перевода строки. Цитировать из документа 3.1.3 Std Lib:
str.translate(map)
Return a copy of the s where all characters have been mapped through the map
which must be a dictionary of Unicode ordinals (integers) to Unicode ordinals,
strings or None. Unmapped characters are left untouched. Characters mapped to
None are deleted.
You can use str.maketrans() to create a translation map from
character-to-character mappings in different formats.