Python chr() function

Updated on Nov 10, 2019


The chr() function returns a single character string represented by the integer ordinal value.

Its syntax is as follows:

chr(integer) -> single character string

Here is an example:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
>>> 
>>> chr(65)
'A'
>>>
>>> 
>>> chr(102)
'f' 
>>> 
>>> 
>>> chr(225) # accented a
'á' 
>>> 
>>> 
>>> chr(21325) # swastika
'卍'
>>> 
>>> 
>>> chr(128512) # Grinning Face
'😀'
>>>

Try it out:

print(chr(65))

print(chr(102))

print(chr(225)) # accented a

print(chr(21325)) # swastika

print(chr(128512)) # Grinning Face

To convert the characters back to integers use the ord() function.


Other Tutorials (Sponsors)