How to Check If a String is a Pangram in Python


In this example we will show how to check if a string is a Pangram.

Source Code

#! /usr/bin/env python3
# -*- coding: utf-8 -*-

str = input("Please the string: ")
str = str.lower()
r = set()
for i in str:
    if i >= "a"and i <= "z":
        r.add(i)
if len(r) == 26:
    print("The string is a pangram.")
else:
    print("The string isn't a pangram.")

Output:

Case 1:
Please the string: Python
The string isn't a pangram.

Case 2:
Please the string: All questions asked by five watch experts amazed the judge.
The string is a pangram.
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments