Created
July 27, 2016 04:13
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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