String Translate in Python
Level 3105 keystrokes
This replaces characters using a translation table created with str.maketrans().
Python code
# Create a string to transform1text = "hello world"# maketrans creates mapping: a->1, e->2, i->3, o->4, u->52table = str.maketrans("aeiou", "12345")# translate applies the character mapping3result = text.translate(table)# Print: h2ll4 w4rld (vowels replaced with numbers)4print(result)Output
h2ll4 w4rld
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=× 3.× 2,× 1