Skip to content

Instantly share code, notes, and snippets.

@atmb4u
Created July 27, 2016 04:13
Show Gist options
  • Save atmb4u/4615e2c60276ef8c7b50d50506cb39f1 to your computer and use it in GitHub Desktop.
Save atmb4u/4615e2c60276ef8c7b50d50506cb39f1 to your computer and use it in GitHub Desktop.
python function generate unicode superscript of a number and print it in command line
#!/usr/bin/python
# -*- coding: utf-8 -*-
power_dict = [
"⁰",
"¹",
"²",
"³",
"⁴",
"⁵",
"⁶",
"⁷",
"⁸",
"⁹"
]
def superscript(n):
"""
To generate unicode superscript of a number and print it in command line
n - number of any arbitrary length
"""
return "".join([power_dict[int(q)] for q in list(str(n))])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment