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)
ExampleEdit & Run
print(ord('a'))
print(ord('n'))
print(ord('z'))
Output:
97110122[Finished in 0.010643318993970752s]
ExampleEdit & Run
for i in 'Python':
    print("{} : {}".format(i, ord(i)))
Output:
P : 80y : 121t : 116h : 104o : 111n : 110[Finished in 0.010471648070961237s]

The argument given should strictly be a single character.

ExampleEdit & Run
ord('Python')
Output:
Traceback (most recent call last):  File "<string>", line 1, in <module>TypeError: ord() expected a character, but string of length 6 found[Finished in 0.01045425608754158s]

The chr function serves the opposite purpose, where you give it an integer argument and it returns the unicode character represented by the integer.