Python chr()

The chr() function returns a character that represents the specified unicode.

Syntax

chr(i)

  • The chr() method takes only one integer as argument.
  • The range may vary from 0 to 1,1141,111(0x10FFFF in base 16).
  • The chr() method returns a character whose unicode point is num, an integer.
  • If an integer is passed that is outside the range then the method returns a ValueError.

Example

Creating a String use ASCII characters.

print(chr(67),chr(79),chr(68),chr(69),chr(32),chr(73),chr(84))

Output

C O D E   I T

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s