How to Create an Alphabet List in 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...
Hardik Savani
I'm a full-stack developer, entrepreneur and owner of ItSolutionstuff.com. I live in India and I love to write tutorials and tips that can help to other artisan. I am a big fan of PHP, Laravel, Angular, Vue, Node, Javascript, JQuery, Codeigniter and Bootstrap from the early stage. I believe in Hardworking and Consistency.
We are Recommending you
- How to Get Smallest Number in List Python?
- Python Remove Character from List of Strings Example
- How to Replace Value in Python List?
- Python Generate List of Random Float Numbers Example
- How to Create a List of Numbers from 1 to 100 in Python?
- How to Get Last n Elements of a List in Python?
- Python Remove Last 2, 3, 4, 5, 10, etc Elements from List Example
- Python Dictionary Convert Keys to List Example
- Python List Add Element at Beginning Example
- How to Add Element at the End of List in Python?
- How to Add Element at Specific Index in Python List?
- How to Add Element to a List in Python?
- Python List Print All Elements Except First Example
- Python List Print All Elements Except Last Example