⊕
⊖
Contents
Next ASCII Character
To get the next ASCII character, for a given character, we use ord() builtin function to get the ASCII value of given character, increment it by one, and then use chr() builtin function to get the character for this incremented ASCII value.
Example
In this example, we will read a character (a string of length one) into x from user, and find the next ASCII character.
Python Program
x = input('enter a character : ')
ascii = ord(x)
next_char = chr(ascii + 1)
print('next character :', next_char)
CopyOutput
enter a character : r
next character : s
Summary
In this tutorial of Python Examples, we learned how to get the next ASCII character for a given character.
Next Topic ⫸ Python Escape characters
⫷ Previous Topic Python String upper()