Answers for "How do you print superscript in Python"

2

superscript print python

print("Superscript: xu00b2")
Posted by: Guest on March-08-2020
0

how to write subscript and superscript in python

# function to convert to subscript
def get_sub(x):
    normal = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-=()"
    sub_s = "ₐ₈CDₑբGₕᵢⱼₖₗₘₙₒₚQᵣₛₜᵤᵥwₓᵧZₐ♭꜀ᑯₑբ₉ₕᵢⱼₖₗₘₙₒₚ૧ᵣₛₜᵤᵥwₓᵧ₂₀₁₂₃₄₅₆₇₈₉₊₋₌₍₎"
    res = x.maketrans(''.join(normal), ''.join(sub_s))
    return x.translate(res)
  
# display subscript
print('H{}SO{}'.format(get_sub('2'),get_sub('4'))) #H₂SO₄
Posted by: Guest on June-16-2021

Code answers related to "How do you print superscript in Python"

Python Answers by Framework

Browse Popular Code Answers by Language