C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Python String translate() MethodPython translate() method a string in which each character has been mapped through the given translation table. We can use maketrans() method to create a translation map from character-to-character mappings in different formats. Signature
translate(table) Parameters
table : A translation table. ReturnIt returns a string. Let's see some examples of translate() method to understand it's functionality. Python String translate() Method Example 1
# Python translate() method
# Declaring table and variables
table = { 97 : 103, 111 : 112, 117 : None }
str = "Hello TheDeveloperBlog"
# Calling function
str2 = str.translate(table)
# Displaying result
print(str2)
Output: Hellp jgvgtppint
Next TopicPython Strings
|