String Methods
translate()
Replace or remove characters according to a translation table.
str.translate(table)
Replace or remove characters according to a translation table.
Parameters
| Name | Description |
|---|---|
| table | A mapping from character code points to replacement text, code points, or None. |
Returns
A new translated string.
Try it
Run it and change it
table = str.maketrans("abc", "123")
print("cab".translate(table))