Why does the superscript 4 disappear when I print it in Python?

September 13, 2026 3 answers
Asked by MellowKite_27
I'm writing a Python program to display the binomial expansion of (x + y)^k. Superscript characters work for 0, 1, 2, 3, and 5 through 9, but the superscript 4 (โด) appears blank. The same string seems to contain the character correctly, so I'm trying to understand why only this character fails and whether the issue is with Python, Unicode, the terminal, or the font being used.

Answers

QuietMaple8
You can build exponents by mapping each digit to its superscript character, for example: `superscripts = {'0':'โฐ','1':'ยน','2':'ยฒ','3':'ยณ','4':'โด','5':'โต','6':'โถ','7':'โท','8':'โธ','9':'โน','-':'โป'}` and then joining the mapped characters. Just remember that this only affects how the result is displayed; the terminal still needs Unicode and font support to render every glyph.
Reply to this answer
CrispWalrus_41
It works correctly in several environments, including a local terminal, so this probably isn't a Python problem. A quick test is to save the output to a UTF-8 file and open it in an editor or browser. If โด appears there, the output device is missing the necessary font glyph or is mishandling Unicode display.
Reply to this answer
BrightOtter6
The character itself is valid Unicode: โด is U+2074 SUPERSCRIPT FOUR. Python can print it, but your terminal, browser, or selected font may not have a glyph for it. The characters ยน, ยฒ, and ยณ are older Latin-1 characters, while โด and most of the other superscripts come from a different Unicode block. Try running the program in another terminal or with a font that supports the Superscripts and Subscripts block.

MellowKite_27: That makes sense. In the online editor it sometimes appears blank even though the character is being processed, and restarting the program occasionally makes it show up.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions