- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
chr () in Python
This function return the string representing a character whose Unicode code point is the integer supplied as parameter to this function. For example, chr(65) returns the string 'A', while chr(126) returns the string '~'.
Syntax
The syntax of the function is as below.
chr(n) where n is an integer value
Example
The below program shows how the chr() is used. We supply various integer values as parameter and get back the respective characters.
# Printing the strings from chr() function print(chr(84),chr(85),chr(84),chr(79),chr(82))
Running the above code gives us the following result −
T U T O R
Using a series of numbers
We can take help of python data structures like lists to loop through a series of numbers and apply char function to create a required string. In the below example we see that we have used a list to
Example
str = "" series = [84,85,84,79,82,73,65,76,83] for i in range(0,len(series)): char = chr(series[i]) str = str + char i=i+1 print(str)
Output
Running the above code gives us the following result −
TUTORIALS
Advertisements
To Continue Learning Please Login
Login with Google