How to add characters to a variable/integer name - Python
<p>There might be a question like this but I can't find it.
I want to be to add the name of a variable/integer. e.g.</p>

<pre><code>num = 5
chr(0x2075)
</code></pre>

<p>Now the 2nd line would return 5 in superscript but I want to put the word num into the Unicode instead so something like <code>chr(0x207+num)</code> would return 5 in superscript.</p>

<p>Any ideas? Thanks in advance</p>

<pre><code>chr(0x2070 + num)
</code></pre>

<p>As given in the comment, if you want to get the character at U+207x, this is correct. </p>

<p>But this is <strong><em>not</em></strong> the proper way to find the superscript of a number, because U+2071 is <code>â±</code> (superscript "i") while U+2072 and U+2073 are not yet assigned. </p>

<pre><code>&gt;&gt;&gt; chr(0x2070 + 1)
'â±'
</code></pre>

<p>The real superscripts <code>Â¹</code> (U+00B9), <code>Â²</code> (U+00B2), <code>Â³</code> (U+00B3) are out of place.</p>

<pre><code>&gt;&gt;&gt; chr(0xb9), chr(0xb2), chr(0xb3)
('Â¹', 'Â²', 'Â³')
</code></pre>

<p>Unfortunately, like most things Unicode, the only sane solution here is to hard code it:</p>

<pre><code>def superscript_single_digit_number(x):
    return u'â°Â¹Â²Â³â´âµâ¶â·â¸â¹'[x]
</code></pre>

python variables unicode