Python String translate() Syntax
str.translate(translation_table)
Example:
In the given example, we are using str.translate() method is used to translate a string by specifying a mapping using ASCII values.
Python3
# specifying the mapping using ASCII translation = { 103 : None , 101 : None , 101 : None } string = "geeks" # translate string print ( "Translated string:" , string.translate(translation)) |
Output:
Translated string: ks
Python String translate() Method
Python String translate() returns a string that is a modified string of givens string according to given translation mappings.