How can I convert a character to a integer in Python, and viceversa?

How can I convert a character to a integer in Python, and viceversa?

Use chr() and ord():

>>> chr(97)
a
>>> ord(a)
97
>>> ord(a)
97
>>> chr(97)
a

How can I convert a character to a integer in Python, and viceversa?

ord and chr

Leave a Reply

Your email address will not be published. Required fields are marked *