Printing subscript in python

If all you care about are digits, you can use the str.maketrans() and str.translate() methods: example_string = “A0B1C2D3E4F5G6H7I8J9” SUB = str.maketrans(“0123456789”, “₀₁₂₃₄₅₆₇₈₉”) SUP = str.maketrans(“0123456789”, “⁰¹²³⁴⁵⁶⁷⁸⁹”) print(example_string.translate(SUP)) print(example_string.translate(SUB)) Which will output: A⁰B¹C²D³E⁴F⁵G⁶H⁷I⁸J⁹ A₀B₁C₂D₃E₄F₅G₆H₇I₈J₉ Note that this won’t work in Python 2 – see Python 2 maketrans() function doesn’t work with Unicode for an explanation of … Read more

How to find the unicode of the subscript alphabet?

Take a look at the wikipedia article Unicode subscripts and superscripts. It looks like these are spread out across different ranges, and not all characters are available. Consolidated for cut-and-pasting purposes, the Unicode standard defines complete sub- and super-scripts for numbers and common mathematical symbols ( ⁰ ¹ ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ … Read more