Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Python by (4k points)

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

1 Answer

0 votes
by (8.7k points)

 This can be achieved through the use of below two  function:

  • ord(): helps to extract out the int value of the respective character.

  • chr():helps to again convert the int value into its respective character.

For ex:

ord(‘p’)

>>112

chr(112)

>>p

You can also perform operation like

chr(ord(‘p’)-15)

>>a

Related questions

0 votes
1 answer
asked Jul 2, 2019 in Python by Sammy (47.6k points)
0 votes
0 answers
0 votes
1 answer

Browse Categories

...