How to convert numbers to alphabet? [duplicate]

If you have a number, for example 65, and if you want to get the corresponding ASCII character, you can use the chr function, like this

>>> chr(65)
'A'

similarly if you have 97,

>>> chr(97)
'a'

EDIT: The above solution works for 8 bit characters or ASCII characters. If you are dealing with unicode characters, you have to specify unicode value of the starting character of the alphabet to ord and the result has to be converted using unichr instead of chr.

>>> print unichr(ord(u'\u0B85'))
அ

>>> print unichr(1 + ord(u'\u0B85'))
ஆ

NOTE: The unicode characters used here are of the language called “Tamil”, my first language. This is the unicode table for the same http://www.unicode.org/charts/PDF/U0B80.pdf

Leave a Comment