Tech stuff and info dump

python: generate a list of uppercase or lowercase letters in the alphabet

May 30th, 2010

To create a list of lower-case letters in the alphabet in python:

map(chr, range(97, 123))

To create a list of upper-case letters in the alphabet in python:

map(chr, range(65, 91))

Examples:

>>> map(chr, range(65, 91))
[‘A’, ‘B’, ‘C’, ‘D’, ‘E’, ‘F’, ‘G’, ‘H’, ‘I’, ‘J’, ‘K’, ‘L’, ‘M’, ‘N’, ‘O’, ‘P’, ‘Q’, ‘R’, ‘S’, ‘T’, ‘U’, ‘V’, ‘W’, ‘X’, ‘Y’, ‘Z’]

>>> a=map(chr, range(97, 123))
>>> a
[‘a’, ‘b’, ‘c’, ‘d’, ‘e’, ‘f’, ‘g’, ‘h’, ‘i’, ‘j’, ‘k’, ‘l’, ‘m’, ‘n’, ‘o’, ‘p’, ‘q’, ‘r’, ‘s’, ‘t’, ‘u’, ‘v’, ‘w’, ‘x’, ‘y’, ‘z’]


Filed under: python,script
May 30th, 2010 16:59:09