[Solved] Translate a string using a character map [closed]


The built-in function you seem to be looking for is str.translate:

S.translate(table [,deletechars]) -> string

Return a copy of the string S, where all characters occurring in the optional argument deletechars are removed, and the remaining characters have been mapped through the given translation table, which must be a string of length 256 or None.
If the table argument is None, no translation is applied and the operation simply removes the characters in deletechars.

Alternatively, if you are using a rotation scheme, you may find the chr and ord functions useful:

chr(i) -> character

Return a string of one character with ordinal i; 0 <= i < 256.

ord(c) -> integer

Return the integer ordinal of a one-character string.

solved Translate a string using a character map [closed]