Python program to check if the given string is pangram

PythonServer Side ProgrammingProgramming

In this article, we will learn about the solution and approach to solve the given problem statement.

Problem statement

Given a string input, we need to generate a Python program to check whether that string is Pangram or not.

A pangram is a sentence/ series of words which contains every letter in the English Alphabets collection.

Now let’s see how we can solve the problem

We will use a loop that checks whether each character present in the input string belongs to the alphabet set or not which we will declare manually .

The implementation of the approach above is given by −

Example

 Live Demo

import string
def ispangram(str):
   alphabet = "abcdefghijklmnopqrstuvwxyz"
   for char in alphabet:
      if char not in str.lower():
         return False
   return True
# main
string = 'The five boxing wizards jump quickly.'
if(ispangram(string) == True):
   print("Yes")
else:
   print("No")

Output

Yes

Here we implemented two for loops via membership operators in the nehaced version by specifying an iterable of type string

All variables and functions are declared in global scope as shown in the figure below.

Conclusion

In this article, we learned about the approach to find whether a string is a number pangram or not

raja
Published on 26-Sep-2019 12:24:23
Advertisements