Menu Close

Python chr() Function

In this tutorial, we are going to learn all about the python chr() function to get the character of the specified Unicode.
In the previous python tutorial, we have seen a python callable function to check whether an object is callable or not.

Python chr() function

Python chr function is a built-in function that is used to return the character of specified unicode. It take the unicode and return their character.


The syntax of chr function in python is:-



chr function in python accepts one parameter that is number.

  • number:- An integer represent the unicode character.

Return Value

Return value of chr function in python is character of unicode.

Python chr() function examples

Here we will use python chr() function to find the character of unicode.

Example 1:

#Get the character of 98.
x = chr(98)

Output will be:- b

Example 2:

#Get the character of 50.
y = chr(50)

Output will be:- 2

Example 3:

#get the character of 65.
y = chr(65)

Output will be:- A

Integer passed chr() function is out of range().

When you passed integer out of range in chr() function, The you will get ValueError.


y = chr(-2)


Traceback (most recent call last):
  File "C:\Users\Vishvajit\Desktop\PF Article\Python Basic part1\", line 1, in <module>
    y = chr(-2)
ValueError: chr() arg not in range(0x110000)


In this tutorial, you have learned all about Python chr() function to get the character of specified object. This is the best python built-in function to get the character of unicode character.

Other Python built-in functions

For more information:- Click Here

Python callable() Function
Python eval() Function

Related Posts