Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (47.6k points)

How do I get the ASCII value of a character as an int in Python?

1 Answer

0 votes
by (106k points)

To get the ASCII value of a character in Python we have a function called as ord(), it would get the int value of the char. And in case if you want to convert back char into int then you can use the function chr() which does the trick.

Below is an example that illustrates the use of ord() and char() function respectively:-



print(chr(ord('a') + 3))


If you are using Python 2, then there is also a function which Tells the ASCII value which is unichr():-

print unichr(97)

print unichr(1234)


Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94k users

Browse Categories