#13
Inspired Python
>>> import string
>>> before = string.ascii_lowercase + string.digits
>>> after = '🅐🅑🅒🅓🅔🅕🅖🅗🅘🅙🅚🅛🅜🅝🅞🅟🅠🅡🅢🅣🅤🅥🅦🅧🅨🅩⓿➊➋➌➍➎➏➐➑➒'
>>> translation_table = str.maketrans(before, after)
>>> 'inspired python'.translate(translation_table)
'🅘🅝🅢🅟🅘🅡🅔🅓 🅟🅨🅣🅗🅞🅝'

Python Strings: Using translation tables to make Unicode text


Python strings can map one character to another using a translation table of character mappings. You can use it to great effect to, for example, generate unicode text using ASCII as the input.

Be Inspired Get Python tips sent to your inbox

We'll tell you about the latest courses and articles.

Absolutely no spam. We promise!