Function Details: maketrans

Description


Return a translation table usable for str.translate().


Extended Description


The maketrans() method creates a translation table that can be used with the translate() method to replace specified characters. It can be called in two ways: with a dictionary mapping characters to their replacements, or with two strings of equal length where characters in the first string are replaced by the corresponding characters in the second string.


Read More about maketrans from Python Documentation

Function Signature



Module: builtins

Class: str

Parameters



Parameter List


  • x: Union[dict, str]
  • y: str
  • z: str

Return


Returns a dictionary suitable for use with translate().


Return Type


dict

Output

Explanation

This example demonstrates creating a translation table to replace 'a' with '1', 'b' with '2', and 'c' with '3'.