Python Pangram Program


A Pangram string is a string that contains all English alphabet at least once.


  • “How vexingly quick daft zebras jump!”
  • “The five boxing wizards jump quickly.”
  • “The quick brown fox jumps over the lazy dog.”

To check if the given string is a pangram or not,

  • Take all the characters from a to z in a string, and let us call it a to z string.
  • For each character from the above a to z string, check if the character is present in the given string.
    • If the character is not present, then it is not a Pangram.
  • If all the characters in a to z string are present in the given string, then it is a Pangram.


In the following program, we define a function isPangram(), that takes a string as argument, checks if the given string is a Pangram or not, and returns a boolean value.

Python Program

def isPangram(s):
    s = s.lower()
    for char in 'abcdefghijklmnopqrstuvwxyz':
        if char not in s:
            return False
    return True

s = 'The quick brown fox jumps over the lazy dog.'
if isPangram(s):
    print('A Pangram.')
    print('Not a Pangram.')
Run Code Copy

Output #1

A Pangram.

You may try the above program, with different values assigned to variable s.


In this tutorial of Python General Programs, we learned how to check if a given string or number is a Pangram or not.

Related Tutorials

Code copied to clipboard successfully 👍