How to Use chr() Function in PythonPython Basics


The chr() function gets a character whose Unicode code point is the integer x.

Example

#!/usr/bin/python3
# -*- coding: UTF-8 -*-


print("chr(97):  ", chr(97))

print("chr(98):  ", chr(98))

print("chr(89):  ", chr(89))

print("chr(90):  ", chr(90))

Output:

chr(97):   a
chr(98):   b
chr(89):   Y
chr(90):   Z

Syntax

char(x)

Parameters

The function doesn’t take any parameters.

Return Value

It returns a character.

© 2024 Cheerlearn.com, all rights reserved. Privacy Policy | Contact Us