Program to check given string is pangram or not in Python



Suppose we have a string s, this is representing a sentence, we have to check whether every letter of the English alphabet is used at least once or not.

So, if the input is like "The grumpy wizards make toxic brew, for the evil queen and Jack", then the output will be True

To solve this, we will follow these steps −

  • s:= make all letters of s into lowercase letters
  • a:= 0
  • for each i in English alphabet, do
    • if i is not in s, then
      • return False
  • return True

Let us see the following implementation to get better understanding −

Example

 Live Demo

import string
class Solution:
   def solve(self, s):
      s=s.lower()
      a=0
      for i in string.ascii_lowercase :
         if i not in s :
            return False
      return True
s = "The grumpy wizards make toxic brew, for the evil queen and Jack"
ob = Solution()
print(ob.solve(s))

Input

"The grumpy wizards make toxic brew, for the evil queen and Jack"

Output

True

Advertisements