Python chr() Method

The chr() method returns the string representing a character whose Unicode code point is the integer.

Syntax:

chr(integer)

Parameters:

integer: Required. An integer from 0 through 1,114,111 (0x10FFFF in base 16).

Return type:

Returns a string.

The following example returns characters from the given integer arguments.

Example: Int to Char
print("The character value of 65 is: ", chr(65))
print("The character value of 90 is: ", chr(90))
print("The character value of 97 is: ", chr(97))
print("The character value of 122 is: ", chr(122))
print("The character value of 1200 is: ", chr(1200))
Output
The character value of 65 is:  A
The character value of 90 is:  Z
The character value of 97 is:  a
The character value of 122 is:  z
The character value of 1200 is:  Ұ

If the specified integer is out of range, then the ValueError exception is thrown.

Example: chr()
print(chr(-1))
Output
ValueError: chr() arg not in range(0x110000)
Want to check how much you know Python?