
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Check if a string is Pangrammatic Lipogram in Python
Suppose, we have been provided with three strings and we are asked to find which of the strings are a Pangram, Lipogram, and a Pangrammatic Lipogram. A Pangram is a string or a sentence, where every letter in the alphabet appears at least once. A Lipogram is a string or a sentence where one or more letters in the alphabet do not appear. A Pangrammatic Lipogram is a string or sentence where all letters in the alphabet appear except one.
So, if the input is like −
pack my box with five dozen liquor jugs to stay in this mortal world or by my own hand go to oblivion, that is my conundrum. the quick brown fox jumps over a lazy dog waltz, nymph, for quick jigs ve bud,
then the output will be −
The String is a Pangram The String isn't a Pangram but might be a Lipogram The String is a Pangram The String is a Pangrammatic Lipogram
To solve this, we will follow these steps −
- convert all letters in the string to lowercase alphabets.
- i := 0
- for each character in the lowercase alphabet, do
- if character is not found in input_string, then
- i := i + 1
- if character is not found in input_string, then
- if i is same as 0, then
- output := "The String is a Pangram"
- otherwise when i is same as 1, then
- output := "The String is a Pangrammatic Lipogram"
- otherwise,
- output := "The String isn't a Pangram but might be a Lipogram"
- return output
Example
Let us see the following implementation to get better understanding −
import string def solve(input_string): input_string.lower() i = 0 for character in string.ascii_lowercase: if(input_string.find(character) < 0): i += 1 if(i == 0): output = "The String is a Pangram" elif(i == 1): output = "The String is a Pangrammatic Lipogram" else: output = "The String isn't a Pangram but might be a Lipogram" return output print(solve("pack my box with five dozen liquor jugs")) print(solve("to stay in this mortal world or by my own hand go to oblivion,that is my conundrum.")) print(solve("the quick brown fox jumps over a lazy dog")) print(solve("waltz, nymph, for quick jigs ve bud"))
Input
pack my box with five dozen liquor jugs to stay in this mortal world or by my own hand go to oblivion, that is my conundrum. the quick brown fox jumps over a lazy dog waltz, nymph, for quick jigs ve bud
Output
The String is a Pangram The String isn't a Pangram but might be a Lipogram The String is a Pangram The String is a Pangrammatic Lipogram
- Related Articles
- Check if a string is Colindrome in Python
- Python - Check if a variable is string
- How to check if a string is alphanumeric in Python?
- Check if a string is Isogram or not in Python
- Check if a string is suffix of another in Python
- Check if a given string is a valid number in Python
- Python - Check if a given string is binary string or not
- How to check if a string in Python is in ASCII?
- How to check if a string is a valid keyword in Python?
- How to check if type of a variable is string in Python?
- How to check if a character in a string is a letter in Python?
- Python Program to check if a substring is present in a given string.
- How to check if a substring is contained in another string in Python
- Python program to check if a string is palindrome or not
- Python program to check if a given string is number Palindrome

Advertisements