Python Practice › String Programs › Program 63
Does a string contain every letter?
Write a Python program to check whether a string contains all letters of the alphabet (a pangram).
Input
"abcdgjksoug", "The quick brown fox jumps over the lazy dog"
Output
False True
Approach
- Compare the set of letters with
string.ascii_lowercase.
Solution
import string for text in ["abcdgjksoug", "The quick brown fox jumps over the lazy dog"]: print(set(string.ascii_lowercase) <= set(text.lower()))Output
False True
Learn the concept
New to this topic? Read the lesson, then come back.