Alphabet range in Python
In Python, you can use the string
module's ascii_lowercase
and ascii_uppercase
constants to get the range of lowercase and uppercase letters in the ASCII character set respectively. Here is an example code snippet:
import string
lowercase_alphabet = string.ascii_lowercase
print(lowercase_alphabet)
uppercase_alphabet = string.ascii_uppercase
print(uppercase_alphabet)
This will output:
abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
Watch a video course
Python - The Practical Guide
You can also use the string.ascii_letters
which will contain both the uppercase and lowercase letters.
This will output:
abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ