Python Pangram Program

Pangram

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

Examples

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

Program

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.')
else:
    print('Not a Pangram.')
Run Code

Output #1

A Pangram.

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

Summary

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

Privacy Policy Terms of Use

SitemapContact Us