Alphabet Websites - One Letter Per Site

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 )]



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

Uppercase Letters

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


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