Problem Statement
You have to check if given string is a Pangram or not.
A Pangram string is a string that contains all English alphabet at least once.
Some of the examples for Pangram strings are:
"How vexingly quick daft zebras jump!"
"The five boxing wizards jump quickly."
"The quick brown fox jumps over the lazy dog."
"Jack amazed a few girls by dropping the antique onyx vase."
Input
The first line of input is a string: s
.
Output
Print Pangram
if the given string is a Pangram string, or Not Pangram
if the given string is not a Pangram string.
As is
The boilerplate code is already there to read the inputs from user, in the main()
function, and to print the message to output based on the boolean value returned by isPangram()
function. Do not edit this code.
To do ✍
isPangram()
has one parameter: s
. Write code inside the function body to check if the given string s
is a Pangram string or not, and return a boolean value of True
if the string is a Pangram, or False
otherwise.
Note: Ignore case, while comparing the characters.
Example 1
Test input
The five boxing wizards jump quickly
Test output
Pangram
Explanation
The given string contains all the English alphabets at least once. Hence, a Pangram string.
Example 2
Test input
Hello World
Test output
Not Pangram
Explanation
The string 'Hello World'
does not contain all the English characters from a to z.
Useful References
- Python – Convert string to lowercase
- Python – Iterate over characters in a string
- Python – Check if specific character is in a string
- Python not in
Python Program
# Complete the following function
# Return boolean value:
# True : if given string is a Pangram
# False : if given string is not a Pangram
def isPangram(s):
# Boilerplate code - Do not edit the following
def main():
s = input()
if isPangram(s):
print("Pangram")
else:
print("Not Pangram")
if __name__ == "__main__":
main()
Testcase 1
The five boxing wizards jump quickly
Pangram
Testcase 2
hello world
Not Pangram
Testcase 3
abcdefGHIJklmnopqrstuvwxyz
Pangram
Testcase 4
The quick brown fox jumps over the lazy dog.
Pangram
# Complete the following function
def isPangram(s):
s = s.lower()
for char in 'abcdefghijklmnopqrstuvwxyz':
if char not in s:
return False
return True
# Boilerplate code - Do not edit the following
def main():
s = input()
if isPangram(s):
print("Pangram")
else:
print("Not Pangram")
if __name__ == "__main__":
main()