HOWTO · Python
How to List the Alphabet in Python
This article demonstrates how to list all the alphabet in Python
On this page
To store the 26 lowercase English letters in a Python list, convert the standard-library string constant string.ascii_lowercase with list(). The result is a list with one character per item. This is the clearest option when you need the English alphabet as a ready-made sequence.
Create a list with string.ascii_lowercase
The Python string module provides constants for common groups of characters. string.ascii_lowercase is the string abcdefghijklmnopqrstuvwxyz; converting it with list() gives a list of its 26 individual letters. Import string before using the constant.
Run this example:
import string
letters = list(string.ascii_lowercase)
print(letters)
['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']
For uppercase English letters, use string.ascii_uppercase in the same expression. These constants are strings, so list() splits them into characters; they do not produce a list until converted.
Generate letters with range() and map()
You can also build the list from character code points. The range() function produces integers from its start up to, but not including, its stop value. The map() function applies another function to each item in an iterable. Here, map(chr, ...) converts each integer to the corresponding character, and list() collects the results.
Run this example:
letters = list(map(chr, range(97, 123)))
print(letters)
['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']
The lowercase English letters have code points 97 through 122 in ASCII. Because range() excludes its stop value, use 123 to include the code point for z (122). If the stop value were 122, the generated list would end at y.
Generate letters with ord() and a list comprehension
A list comprehension expresses the same conversion directly. The ord() function returns a character’s Unicode code point, while chr() converts a code point back to a character. Starting at ord("a") and stopping after ord("z") avoids relying on numeric values written by hand.
Run this example:
letters = [chr(code_point) for code_point in range(ord("a"), ord("z") + 1)]
print(letters)
['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']
The + 1 includes the code point for z, since the range() stop remains exclusive. This version is useful when the starting or ending character should come from a variable or another input.
Choose a method and understand the character range
Use string.ascii_lowercase for a concise, readable list of the 26 lowercase English letters; choose string.ascii_uppercase for uppercase letters. The range() with map() and the ord() comprehension show how character conversion works and are easier to adapt when you need a sequence based on chosen endpoints.
These examples cover the English alphabet, whose letters occupy a consecutive range in ASCII. Python’s ord() and chr() work with Unicode code points, not only ASCII. However, incrementing code points from one endpoint does not generate every writing system’s alphabet: many alphabets have characters outside this interval or do not form one consecutive sequence. For a different alphabet, use an explicitly defined sequence of the characters you need rather than assuming a numeric range will match it.