chr()
function is used to find the character in the form of string in Python, from an input value (i
– integer) that represent the unicode
point of that character.
chr()
function is a part of Python Built-in Functions.
Syntax of chr()
Function
The syntax of chr()
function in Python is:
chr(i)
Parameters of chr()
Function in Python
i
– Where i
is any valid integer from 0
to 1,114,111
.
Compatibility
chr()
function is available and compatible with both Python 2.x
and 3.x
.
Return Value of chr()
Function in Python
chr()
function returns the string representing a character whose Unicode code point is the integer i
for the given input.
chr()
Function Exception
If parameter
i
is outside the range of 0
to 1,114,111
then the chr()
throw a ValueError
.
Python chr()
Function Example 1
print(chr(82)) print(chr(35)) print(chr(1230)) print(chr(102)) print(chr(1400))
Output:
R
#
ӎ
f
ո
Python chr()
Function Example 2
print(chr(-7))
Output:
Error