In this tutorial, we will look at how to convert an integer to a char in Python with the help of some examples. We’ll be looking at use-cases of finding the char (string) representing a character whose Unicode point is the integer.
How to convert integer to char in Python?

You can use the Python built-in chr()
function to get the character represented by a particular integer in Unicode. The following is the syntax –
chr(i)
Pass the integer as an argument. The valid range for the integer argument is from 0 through 1,114,111 (0x10FFFF in base 16). If you pass an integer outside of this range, it will result in a ValueError
.
Examples
Let’s look at some examples of using the above syntax –
Get the character represented by a number in Unicode
Let’s pass the integer 65 to the chr()
function.
# integer to char ch = chr(65) # display char and its type print(ch) print(type(ch))
Output:
A <class 'str'>
We get 'A'
from the function. The number 65 points to the character 'A'
in Unicode.
Let’s look at another example.
Introductory ⭐
- Harvard University Data Science: Learn R Basics for Data Science
- Standford University Data Science: Introduction to Machine Learning
- UC Davis Data Science: Learn SQL Basics for Data Science
- IBM Data Science: Professional Certificate in Data Science
- IBM Data Analysis: Professional Certificate in Data Analytics
- Google Data Analysis: Professional Certificate in Data Analytics
- IBM Data Science: Professional Certificate in Python Data Science
- IBM Data Engineering Fundamentals: Python Basics for Data Science
Intermediate ⭐⭐⭐
- Harvard University Learning Python for Data Science: Introduction to Data Science with Python
- Harvard University Computer Science Courses: Using Python for Research
- IBM Python Data Science: Visualizing Data with Python
- DeepLearning.AI Data Science and Machine Learning: Deep Learning Specialization
Advanced ⭐⭐⭐⭐⭐
- UC San Diego Data Science: Python for Data Science
- UC San Diego Data Science: Probability and Statistics in Data Science using Python
- Google Data Analysis: Professional Certificate in Advanced Data Analytics
- MIT Statistics and Data Science: Machine Learning with Python - from Linear Models to Deep Learning
- MIT Statistics and Data Science: MicroMasters® Program in Statistics and Data Science
🔎 Find Data Science Programs 👨💻 111,889 already enrolled
Disclaimer: Data Science Parichay is reader supported. When you purchase a course through a link on this site, we may earn a small commission at no additional cost to you. Earned commissions help support this website and its team of writers.
# integer to char ch = chr(44) # display char and its type print(ch) print(type(ch))
Output:
, <class 'str'>
We get the comma character, ','
for the integer 44.
You can use the Python built-in ord()
function to get the corresponding integer for a character in Unicode.
# char to integer print(ord('A')) print(ord(','))
Output:
65 44
We get 65 for the character ‘A’ and 26 for the character ‘$’.
What if you pass a negative integer to the above function?
Let’s pass a negative integer to the chr()
function as an argument.
# integer to char ch = chr(-65) # display char and its type print(ch) print(type(ch))
Output:
--------------------------------------------------------------------------- ValueError Traceback (most recent call last) Input In [20], in <module> 1 # integer to char ----> 2 ch = chr(-65) 3 # display char and its type 4 print(ch) ValueError: chr() arg not in range(0x110000)
We get a ValueError
. This is because the passed integer is outside the valid range of 0 through 1,114,111.
You might also be interested in –
Subscribe to our newsletter for more informative guides and tutorials.
We do not spam and you can opt out any time.