The syntax of chr() is:
The chr() method takes a single parameter, an integer i.
The valid range of the integer is from 0 through 1,114,111.
Return Value from chr()
The chr() returns:
- a character (a string) whose Unicode code point is the integer i
If the integer i is outside the range,
ValueError will be raised.
Example 1: How chr() works?
print(chr(97)) print(chr(65)) print(chr(1200))
When you run the program, the output will be:
a A Ұ
Example 2: Integer passed to chr() is out of the range
When you run the program, ValueError is raised.
It's because the argument passed to the chr() method is out of the range.
The reverse operation of the
chr() function can be performed by the
ord() function. To learn more, visit Python ord() function