The ord()
function is used to return the Unicode integer code of a specified character. The function takes a string containing a single character as its only argument.
syntax:
ord(character)
print(ord('a'))
print(ord('n'))
print(ord('z'))
for i in 'Python':
print("{} : {}".format(i, ord(i)))
The argument given should strictly be a single character.
ord('Python')
The chr function serves the opposite purpose, where you give it an integer argument and it returns the unicode character represented by the integer.