Alphabet Websites - One Letter Per Site

March - 2022

Lowercase Letters

This code can be used when you only need a sub-set of letters (e.g "a" thru "e"):

letters_lowercase = [chr(c) for c in range(ord('a'), ord('a') + 5 )]

print(letters_lowercase)

Outputs:

['a', 'b', 'c', 'd', 'e']

Uppercase Letters

letters_lowercase = [chr(c) for c in range(ord('A'), ord('A') + 5 )]

print(letters_lowercase)

Which outputs:

['A', 'B', 'C', 'D', 'E']

How It Works -

Beyond List Comprehensions (which I'm still getting my head around), there are two keys to making this work:

  1. ord() which turns a character into a number, and
  2. chr() which turns a number into a character

TKTKTKT