How to Create an Alphabet List in Python?

By Hardik Savani October 30, 2023 Category : Python

Hi Guys,

I am going to show you an example of python get all alphabets. I explained simply step by step how to make alphabet letters list in python. you can understand a concept of python list of alphabets. This example will help you how to make alphabet list in python.

We can use string library to get alphabet list in python. string library provide string.ascii_lowercase, string.ascii_letters and string.ascii_uppercase attribute to make list of alphabet letters in python. let's see the one by one example:

Example 1:

main.py

import string
  
# Get All Alphabet List in Lowercase in Python
alphabets = list(string.ascii_lowercase)
print(alphabets)

Output:

['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']

Example 2:

main.py

import string
  
# Get All Alphabet List in Uppercase in Python
upperAlphabets = list(string.ascii_uppercase)
print(upperAlphabets)

Output:

['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']

Example 3:

main.py

import string
  
# Get All Alphabet List in Uppercase & Lowercase in Python
letters = list(string.ascii_letters)
print(letters)

Output:

['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', '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']

I hope it can help you...

Tags :
Shares