String Maketrans in Python
Level 287 keystrokes
This creates a translation table and translates vowels to numbers.
Python code
# str.maketrans builds a table that maps each character of "aeiou" to the one at the same position in "12345"# So a→1, e→2, i→3, o→4, u→51table = str.maketrans("aeiou", "12345")# translate(table) replaces every character found in the table# In "hello", e becomes 2 and o becomes 4; other letters stay2result = "hello".translate(table)# Prints h2ll43print(result)Output
h2ll4
Practice typing this code. Results are not recorded in the rankings.
Symbols in this code
The symbols you type in this Python code and how often they appear.
"× 6(× 3)× 3.× 2=× 2,× 1