# ROT-style char mapping table = str.maketrans("abc", "xyz") print("cab".translate(table)) # zxy
maketrans builds a mapping