Skip to main content

chr()

The chr() function in Python returns the character that represents the Unicode code point passed as an argument. It takes an integer representing a Unicode code point and returns the corresponding character. This function is useful for converting numbers to their corresponding ASCII characters.

Parameter Values

Parameter Description
i

An integer representing a Unicode code point.

Return Values

The chr() function returns a string representing a character in Unicode.

How to Use chr() in Python

Example 1:

The chr() function returns a Unicode character for the specified Unicode code.

print(chr(8364))
Example 2:

It takes an integer argument representing a Unicode code point and returns the corresponding character.

unicode_code = 9731
print(chr(unicode_code))
Example 3:

You can use chr() to convert an iterable of Unicode code points into characters.

unicode_codes = [65, 66, 67]
characters = [chr(code) for code in unicode_codes]
print(characters)