A pangram is a sentence that uses every letter of the alphabet at least once — the classic example is "The quick brown fox jumps over a lazy dog." This post shows how to check whether any given sentence is a pangram in Python.

The cleanest way to solve this uses sets: collect the unique letters actually used in the sentence, then check whether that set contains all 26 letters of the alphabet.

Python Program to Check Whether a String is a Pangram

import string

def is_pangram(sentence):
    letters_used = set(sentence.lower())
    alphabet = set(string.ascii_lowercase)
    return alphabet.issubset(letters_used)

sentence = "The quick brown fox jumps over a lazy dog"

if is_pangram(sentence):
    print(f'"{sentence}" is a pangram.')
else:
    print(f'"{sentence}" is not a pangram.')

Output:

"The quick brown fox jumps over a lazy dog" is a pangram.

sentence.lower() is passed straight to set(), which turns the string into a set of its individual characters — that set naturally includes spaces and punctuation too, but that's fine, since issubset() only checks whether alphabet's 26 letters are all present; it doesn't care about anything extra. Try it with a non-pangram like "Hello world" and it correctly prints that the sentence is not a pangram, since most letters are missing.

This is a good example of reaching for a set when a problem is really about membership and uniqueness rather than order — it's far shorter than looping through the alphabet and checking each letter by hand.