Run
# Given string x = "hello world" # Define a mapping table table = str.maketrans('lo', 'pm') print(f"Mapping table : {table}") # Translate given string x_translated = x.translate(table) print(f"Original : \"{x}\"") print(f"Translated : \"{x_translated}\"")
Output