The Python chr function is a built-in function that returns a string representing a character whose Unicode is an integer. This function is the reverse of the ord() function, which takes a number and outputs it’s ASCII equivalent.

Syntax

chr(number)

The range of the number can be anywhere between 0 to 1,114,111. Anything outside this range will result in a ValueError. It will return for each number, it’s corresponding Unicode String.

For example, chr(98) will return the character b as the value of b in Unicode/ASCII is 98.

Examples

See the following examples below to get an idea how the chr() returns values. The first 128 values in Unicode are also part of the ASCII table. ASCII is actually a sub set of Unicode. Starting from 65 to 122, you will find all the alphabets (Both capitol and non capitol).

For further information, here’s a link to an ASCII table which contains all 128 of it’s characters.

>>> chr(97)
'a'

>>> chr(105)
'i'

>>> chr(136)
'\x88'

>>> chr(567)
'ȷ'

>>> chr(10333)
'⡝'

This marks the end of the Python chr Function. Here’s a link back to the main Python Built-in Functions page.