Python Alphabet | Ways to Initialize a List of the Alphabet
Sometimes while working with the alphabet in python, to make our task easy, we want to initialize a list containing all the alphabets. If we do not know how to do it using python, we will manually type all the alphabets, which will be quite a time taking. In this article, we will learn many different ways of initializing a list containing the alphabets in uppercase, lowercase, in both uppercase and lowercase. We will also learn how to do various operations on alphabets.
Python Alphabets are the same as the lower-level C programming language. They have a unique ASCII value attached to them. With the help of these ascii values, you can convert them into characters and numbers. In this post, we’ll go through all the ways to create a list of alphabets.
In every programming language, including python, every alphabet has a unique ASCII value. We can convert those ASCII values into alphabets using chr and ord functions.
Generating a list of Alphabets in Python
There are many ways to initialize a list containing alphabets, and we will start with the naïve way.
General Approach for Python Alphabet
The ASCII value of A-Z lies in the range of 65-90, and the for a-z, the value is in the range 97 – 122. What we will do is that we will run the loop in this range and using chr(), we will convert these ASCII values into alphabets.
A-Z:

a-z:
Python Alphabet using list comprehension
We can initialize the variable with either ‘a’ or ‘A’ and keep incrementing the ASCII value of the variable. We will run the loop 26 times as there are 26 alphabets in the English language.
Python Alphabet using map function
We can also use the map function to produce the list of alphabets, let’s see how.
Importing the String Module
We can also import the string module, and use its functions to make a list of alphabets without any hassle.
How to check if the character is Alphabet or not in Python
If we want to check if the character is an alphabet or not, we can use the if condition or the built-in function. Let’s see how.
Using If Condition
Using built-in function
We can also use the isalpha() method to check whether the character is an alphabet or not.
How to Convert alphabet into ASCII value
Let us see how we can convert alphabets into their respective ASCII values.
Must Read:
Conclusion
Generally in dynamic programming or while making any application, we need to initialize a Python list containing the alphabets. There are a variety of ways using we can make a list containing all the alphabets like using the string module or by using the ASCII values.
Try to run the programs on your side and let us know if you have any queries.
List the Alphabet in Python

This tutorial shows you how to list the alphabet by the range in Python.
In this tutorial, we want to store the English alphabet’s 26 lowercase characters in a Python list. The quickest way to solve this problem is by making use of the ASCII values of each character and using pre-existing functions in Python.
Use Utils From Module string to List the Alphabet in Python
The Python module string is readily available and contains pre-defined constant values that we can use for this problem. The constant string.ascii_lowercase contains all 26 lowercase characters in string format.
If you perform print(string.ascii_lowercase) , it will result in the following output:
Therefore, we can use this constant and convert it into a list of characters to produce a list of the alphabet.
If you prefer the alphabet list to be in uppercase, then you should use string.ascii_uppercase and reuse the code above and will produce the same output, but in uppercase format.
Use range() to List the Alphabet in Python
range() is a function that outputs a series of numbers. You can specify when the function starts and stops with the first and second arguments.
range() and map()
map() is a function that accepts two arguments: the second argument of the function is an iterable or a collection; the first argument is a function to iterate over and handle the second argument.
We’re going to use these two methods to generate a list of the alphabet using the lowercase letters’ ASCII values and map them with the function chr() , which converts integers into their ASCII counterpart.
range() is used to list the integers from 97 until 122. 97 is the ASCII value of the lowercase a and 122 is for z , so if we use map() and chr() to perform the conversion from its ASCII counterpart to its corresponding characters, we would successfully output a list of the lowercase alphabet.
The second argument for range() is 123 because the second argument is exclusive, which means it uses it as a stop condition.
range() and ord()
ord() is practically the reverse of chr() because it converts characters into its ASCII counterpart.
We’ll use ord() as the arguments of range() to make a list of lowercase alphabets.
We loop every output of range() and convert them into lowercase alphabet using chr() .
Both will produce the same output:
To summarize, the easiest way to list the alphabet in Python, whether lowercase or uppercase, is to use pre-defined methods that can handle ASCII values and convert them into their actual counterparts. You can use the constants from the string module and convert them into a list, or you can use range() and use the ASCII values as arguments to generate a list of the alphabet.
Skilled in Python, Java, Spring Boot, AngularJS, and Agile Methodologies. Strong engineering professional with a passion for development and always seeking opportunities for personal and career growth. A Technical Writer writing about comprehensive how-to articles, environment set-ups, and technical walkthroughs. Specializes in writing Python, Java, Spring, and SQL articles.
How to Make a List of the Alphabet in Python

In this tutorial, you’ll learn how to use Python to make a list of the entire alphabet. This can be quite useful when you’re working on interview assignments or in programming competitions. You’ll learn how to use the string module in order to generate a list of either and both the entire lower and upper case of the ASCII alphabet. You’ll also learn some naive implementations that rely on the ord() and chr() functions.
Table of Contents
Using the string Module to Make a Python List of the Alphabet
The simplest and, perhaps, most intuitive way to generate a list of all the characters in the alphabet is by using the string module. The string module is part of the standard Python library, meaning you don’t need to install anything. The easiest way to load a list of all the letters of the alphabet is to use the string.ascii_letters , string.ascii_lowercase , and string.ascii_uppercase instances.
As the names describe, these instances return the lower and upper cases alphabets, the lower case alphabet, and the upper case alphabet, respectively. The values are fixed and aren’t locale-dependent, meaning that they return the same values, regardless of the locale that you set.
Let’s take a look at how we can load the lower case alphabet in Python using the string module:
Let’s break down how this works:
- We import the string module
- We then instantiate a new variable, alphabet , which uses the string.ascii_lowercase instance.
- This returns a single string containing all the letters of the alphabet
- We then pass this into the list() function, which converts each letter into a single string in the list
The table below shows the types of lists you can generate using the three methods:

We can see that we evaluate an expression for each item in an iterable. In order to do this, we can iterate over the range object between 97 and 122 to generate a list of the alphabet. Let’s give this a shot!
While our for loop wasn’t very complicated, converting it into a list comprehension makes it significantly easier to read! We can also convert our more dynamic version into a list comprehension, as show below:
In the final section, you’ll learn how to use the map() function to generate a list of the alphabet in Python.
Using Map to Make a Python List of the Alphabet
In this section, you’ll make use of the map() function in order to generate the alphabet. The map function applies a function to each item in an iterable. Because of this, we can map the chr function to each item in the range covering the letters of the alphabet. The benefit of this approach is increased readability by being able to indicate simply what action is being taken on each item in an iterable.
Let’s see what this code looks like:
Here, we use the map() function and pass in the chr function to be mapped to each item in the range() covering 97 through 123. Because the map() function returns a map object, we need to convert it to a list by using the list() function.
Conclusion
In this tutorial, you learned a number of ways to make a list of the alphabet in Python. You learned how to use instances from the string module, which covers lowercase and uppercase characters. You also learned how to make use of the chr() and ord() functions to convert between Unicode and integer values. You learned how to use these functions in conjunction with a for loop, a list comprehension, and the map() function.
Alphabet range in Python
How do I create a list of alphabet characters, without doing it manually like this?
![]()
9 Answers 9
Alternatively, using range :
Other helpful string module features:
![]()
![]()
![]()
In Python 2.7 and 3 you can use this:
As @Zaz says: string.lowercase is deprecated and no longer works in Python 3 but string.ascii_lowercase works in both
![]()
Here is a simple letter-range implementation:
Code
Demo
![]()
If you are looking to an equivalent of letters[1:10] from R, you can use:
![]()
![]()
This is the easiest way I can figure out:
So, 97 to 122 are the ASCII number equivalent to ‘a’ to and ‘z’. Notice the lowercase and the need to put 123, since it will not be included).
In print function make sure to set the <:c>(character) format, and, in this case, we want it to print it all together not even letting a new line at the end, so end=» would do the job.