Check Pangram in Python

Check whether a sentence is a pangram (contains every letter of the alphabet at least once).

IntermediateString ProgramsExample 24 of 25
check-pangram.py
Run in browser
1# Program to check pangram
2
3import string
4
5sentence = input("Enter a sentence: ").lower()
6
7alphabet_set = set(string.ascii_lowercase)
8letters = set(ch for ch in sentence if ch.isalpha())
9
10if alphabet_set.issubset(letters):
11 print("Pangram")
12else:
13 print("Not a pangram")

Output

Enter a sentence: The quick brown fox jumps over the lazy dog
Pangram

What's going on

We compare the set of all lowercase letters with the set of letters present in the sentence.