Given a string, write a Python program to check if that string is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet.
Input : The quick brown fox jumps over the lazy dog Output : Yes Input : abcdefgxyz Output : No
We have already discussed the naive approach of pangram checking in this article. Now, let’s discuss the Pythonic approaches to do the same.
Approach #1 : Pythonic Naive
This method uses a loop to check if each character of the string belongs to the alphabet set or not.
Approach #2 : Using Python Set
Convert the given string into set and then check if the alphabet set is greater than or equal to it or not. If the string set is greater or equal, print ‘Yes’ otherwise ‘No’.
Approach #3 : Alternative to set method
This is another method that uses Python set to find if the string is Pangram or not. We make set of lowercase alphabets and the given string. If set of given string is subtracted from the set of alphabets, we get to know whether the string is pangram or not.
Approach #4 : ASCII method
Check if each character of the string lies between the ASCII range of lowercase alphabets i.e. 96 to 122.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Check if a String can be converted to Pangram in K changes
- Python program to check if a given string is Keyword or not
- Python program to check if a string is palindrome or not
- Python program to check if string is empty or not
- Missing characters to make a string Pangram
- Python program to check whether the string is Symmetrical or Palindrome
- Python program to check if a string contains all unique characters
- Python program to check if given string is vowel Palindrome
- Using Set() in Python Pangram Checking
- Python | Check if given string can be formed by concatenating string elements of list
- String slicing in Python to check if a string can become empty by recursive deletion
- C Program to Check if a Given String is Palindrome
- Python | Check if string ends with any string in given list
- Program to check if a string contains any special character
- Program to check if first and the last characters of string are equal
- Java program to check whether a string is a Palindrome
- Program to check if the String is Null in Java
- Program to check if the String is Empty in Java
- Program to check if a String in Java contains only whitespaces
- Program to check if input is an integer or a string
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.