Create Alphabet List in Python Tutorial Example

08-Jun-2023

.

Admin

Create Alphabet List in Python Tutorial Example

Hi Dev,

This article goes into detail on creating an alphabet list in a Python tutorial example. step by step explain Python gets all alphabets. you'll learn how to make an alphabet letters list in Python. I’m going to show you about Python list of alphabets. you will do the following things for how to make an alphabet list in Python.

We can use a string library to get an alphabet list in Python. string library provides a string.ascii_lowercase, string.ascii_letters and string.ascii_uppercase attribute to make a 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']

#Python