Answers for "how to 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 to print superscript in python"

Python Answers by Framework

Browse Popular Code Answers by Language