
- 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
Program to check whether the sentence is pangram or not using Python
Suppose we have a sentence s with only lowercase English letters. We have to check whether it is a pangram or not? A string is said to be pangram if it contains all 26 letters present in English alphabet.
So, if the input is like s = "thegrumpywizardmakestoxicbrewfortheevilqueenandjack", then the output will be True as there are 26 letters from a to z.
To solve this, we will follow these steps −
dictb := a new map
for each i in s, do
dictb[i] := (if i is present in dictb[i], then i, otherwise 0) + 1
if size of dictb is same as 26, then
return True
return False
Let us see the following implementation to get better understanding −
Example
def solve(s): dictb = {} for i in s: dictb[i] = dictb.get(i,0) + 1 if len(dictb) == 26: return True return False s = "thegrumpywizardmakestoxicbrewfortheevilqueenandjack" print(solve(s))
Input
"thegrumpywizardmakestoxicbrewfortheevilqueenandjack"
Output
True
- Related Articles
- Program to check given string is pangram or not in Python
- Swift program to check if string is pangram or not
- Python program to check a sentence is a pangrams or not.
- Java Program to Check Whether the Given String is Pangram
- Golang Program to Check Whether the Given String is Pangram
- Python Program to Check Whether a String is a Palindrome or not Using Recursion
- Python program to check whether a list is empty or not?
- Python program to check if the string is pangram
- Python program to check whether a given string is Heterogram or not
- Program to check whether given graph is bipartite or not in Python
- How to Check Whether a String is Palindrome or Not using Python?
- How to check whether a number is prime or not using Python?
- Python program to check if the given string is pangram
- Program to check whether given matrix is Toeplitz Matrix or not in Python
- Program to check whether a binary tree is complete or not in Python

Advertisements