A New Kind Of String Manipulation
Explore how to manipulate strings in Python using the translate() method and translation tables. Understand how to convert characters to bytes for custom transformations and apply these techniques to solve alphametic puzzles with itertools generators.
We'll cover the following...
We'll cover the following...
Python strings have many methods. You learned about some of those methods in the Strings chapter: lower(), count(), and format(). Now I want to introduce you to a powerful but little-known string manipulation technique: the translate() method.
① String translation starts with a translation table, which is just a dictionary that maps one character to another. Actually, ...