w3resource
Python Exercises

Python Exercise: Check whether a string is a pangram or not

Python Functions: Exercise-14 with Solution

Write a Python function to check whether a string is a pangram or not.

Note : Pangrams are words or sentences containing every letter of the alphabet at least once.
For example : "The quick brown fox jumps over the lazy dog"

Sample Solution:-

Python Code:

import string, sys
def ispangram(str1, alphabet=string.ascii_lowercase):
    alphaset = set(alphabet)
    return alphaset <= set(str1.lower())
 
print ( ispangram('The quick brown fox jumps over the lazy dog')) 

Sample Output:

True

Pictorial presentation:

Python exercises: Check whether a string is a pangram or not.

Flowchart:

Flowchart: Python exercises: Check whether a string is a pangram or not.

Python Code Editor:

Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: Write a Python function that that prints out the first n rows of Pascal's triangle.
Next: Write a Python program that accepts a hyphen-separated sequence of words as input and prints the words in a hyphen-separated sequence after sorting them alphabetically.

What is the difficulty level of this exercise?