str_search : Required, Chars to be searched str_replace: Required, Chars to be replaced ( mapped to searched chars ) str_delete : Optional, Chars to be replaced with None ( deleted in final string )
Length of str_search should be equal to length of str_replace
the method maketrans() returns a dictionary ( str_update ) with chars mapped for search and replace and this can be used for translate().
The `translate()` function works with `maketrans()` to replace or remove characters in a string based on a translation table. `maketrans()` helps define a mapping for character replacements or deletions, which `translate()` applies.
Syntax
str.translate(translation_table)
Example 1: Basic Mapping with translate()
Mapping characters with `maketrans()` and applying with `translate()`.