Today we are going to share a Python Program to check if the given string is a pangram or not. If you are a python beginner and want to start learning the python programming, then keep your close attention in this tutorial as I am going to share a Python Program to check if the given string is a pangram or not.
To increase your Python knowledge, practice all Python programs, here is a collection of 100+ Python problems with solutions.
Copy the below python program and execute it with the help of python compiler.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
def checkPangram(s): List = [] # create list of 26 charecters and set false each entry for i in range(26): List.append(False) #converting the sentence to lowercase and iterating # over the sentence for c in s.lower(): if not c == " ": # make the corresponding entry True List[ord(c) -ord('a')]=True #check if any charecter is missing then return False for ch in List: if ch == False: return False return True # Driver Program to test above functions sentence = "The quick brown fox jumps over the little lazy dog" if (checkPangram(sentence)): print '"'+sentence+'"' print "is a pangram" else: print '"'+sentence+'"' print "is not a pangram" |
If you like FreeWebMentor and you would like to contribute, you can write an article and mail your article to [email protected] Your article will appear on the FreeWebMentor main page and help other developers.