In this tutorial, we will learn all about python chr() method.
The chr() method in python returns a string character from an integer. It will represent unicode code which is pointed to the specific character.
The syntax of chr() is:
Python chr() Method Parameters
chr() method takes a single parameter, which is an integer num.
The chr() method can only take a valid range of the integer from 0 to 1,114,111.
Let us see some examples of the chr() method.
Example 1: How chr() works?
When we execute the above program, we will get the following results.
Example 2: Using Negative number with chr() method.
The above program throws an error because we cannot use numbers, not in the chr() method range.
Rules of Python chr()
- It will only return a string character whose Unicode code points are the integer of a given number.
- It will take only integers as an argument.
- If the integer is outside the range, it will throw a ValueError error.