English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Basic tutorial of Python

Flow control in Python

Fonctions en Python

Types de données en Python

File operations in Python

Objects and classes in Python

Date and time in Python

Advanced knowledge of Python

Python reference manual

Python chr() usage and example

Built-in functions in Python

The chr() method returns a character (string) from an integer (representing the Unicode encoding point).

The syntax of chr() is:

chr(i)

chr() parameter

The chr() method takes one parameter, that is, an integeri.

The valid range of integers is from 0 to1,114,111.

chr() return value

chr() returns:

  • is the Unicode code point as an integeriof the character (string)

If the integeriIf out of range, an error ValueError will be raised.

Example1: How does chr() work?

print(chr(97))
print(chr(65))
print(chr(1200))

When running the program, the output is:

a
A
Ұ

Example2: The integer passed to chr() is out of range

print(chr(-1))

When you run the program, a ValueError will be raised.

This is because the parameter passed to the chr() method is out of range.

Built-in functions in Python