Use these!
SUB =
str.maketrans("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",
"₀₁₂₃₄₅₆₇₈₉ₐᵦₑfgₕᵢⱼₖₗₘₙₒₚqᵣₛₜᵤᵥwₓyz₋")
SUP =
str.maketrans("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",
"⁰¹²³⁴⁵⁶⁷⁸⁹ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵠʳˢᵗᵘᵛʷˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵠʳˢᵗᵘᵛʷˣʸᶻ‾")
Here's the code:
original = ['VO₆_Octa', 'FeO₄_Tet', 'FeO₆_Oct', 'BaO₉_Tsf', 'PrO₆_Oct', 'CaO₆_Oct',
'HgO₂_Lin', 'CrO₆_Oct', 'AgO₄_Tet', 'EuO₉_Tsf']
SUB =
str.maketrans("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",
"₀₁₂₃₄₅₆₇₈₉ₐᵦₑfgₕᵢⱼₖₗₘₙₒₚqᵣₛₜᵤᵥwₓyz₋")
SUP =
str.maketrans("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",
"⁰¹²³⁴⁵⁶⁷⁸⁹ᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵠʳˢᵗᵘᵛʷˣʸᶻᵃᵇᶜᵈᵉᶠᵍʰⁱʲᵏˡᵐⁿᵒᵖᵠʳˢᵗᵘᵛʷˣʸᶻ‾")
new = []
for item in original:
x = item.split('_')
new.append(x[0] + "₋" + x[1].translate(SUB))
print(new)
As you might have noticed, some letters don't actually convert properly to lowercase.
This is because the alphabets for subscript and superscript don't actually exist as a proper alphabet in Unicode.
I've used various online converters and could only get the conversions of the letters that you see above (ie: excluding lowercase b,c,d,f,g,q,w,y,z).
However in my opinion, the better way to do this would be to format the string in some markup language (HTML, Latex etc).
You'll have to use simple <sub></sub>
and <sup></sup>
tags in HTML.