Check Pangram

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

IntermediateTopic: String Programs
Back

Python Check Pangram Program

This program helps you to learn the fundamental structure and syntax of Python programming.

Try This Code
# Program to check pangram

import string

sentence = input("Enter a sentence: ").lower()

alphabet_set = set(string.ascii_lowercase)
letters = set(ch for ch in sentence if ch.isalpha())

if alphabet_set.issubset(letters):
    print("Pangram")
else:
    print("Not a pangram")
Output
Enter a sentence: The quick brown fox jumps over the lazy dog
Pangram

Understanding Check Pangram

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

Note: To write and run Python programs, you need to set up the local environment on your computer. Refer to the complete article Setting up Python Development Environment. If you do not want to set up the local environment on your computer, you can also use online IDE to write and run your Python programs.

Table of Contents