Python list of letters a-z | How to make and print example

Use string.ascii_lowercase or string.ascii_uppercase to make a python list of letters a-z. A list of letters a-z means a list should contain all 26 letters of the alphabet.

import string

az_Upper = string.ascii_uppercase
print(az_Upper)

az_Lower = string.ascii_lowercase
print(az_Lower)

But its string contains the alphabet not a list of letters A-Z. To get List of letter from it use a loop and append methods.

Python list of letters a-z Example

Simply python example code creates a string of all uppercase or lowercase a-z letters and prints it.

You have to import the string module for it.

import string

az_Upper = string.ascii_uppercase
list1 = []
for i in az_Upper:
    list1.append(i)

print(list1)

Output:

Python list of letters a-z

If needed both lowercase and upper case letters then use

az_Letter = string.ascii_letters
print(az_Letter)

Do comment if you have any doubts and suggestions on this Python list topic.

Note: IDE: PyCharm 2021.1.3 (Community Edition)

Windows 10

Python 3.7

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.