chr() and ord()
Built-in functions that convert between a character and its Unicode code point: ord('A') is 65 and chr(65) is 'A'.
In more detail
ord takes a string of exactly one character and returns an integer; chr does the reverse. Because letters have consecutive code points, chr(ord('a') + 1) is 'b'.
Related terms
- string — A sequence of characters, that is, a piece of text.
- integer — A whole number with no fractional part, such as 7, 0 or -12, which Python calls int.
Taught in
- Strings: Escapes, Slices And Methods — PCEP Certified Entry-Level Python Programmer (PCEP-30-02) Exam Prep
- Characters As Numbers — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep
- Strings Sprint — PCAP Certified Associate in Python Programming (PCAP-31-03) Exam Prep