-
Notifications
You must be signed in to change notification settings - Fork 617
/
check_pangram.py
54 lines (30 loc) · 995 Bytes
/
check_pangram.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
'''
Program to check if a given string is pangram or not
A pangram is a sentence containing every letter in the English Alphabet.
'''
#importing the string module
from string import *
#Function to check the string
def pangram(string):
for alpha in ascii_lowercase:
#checking for all the alphabets in the input string
#converting all the letters in lowercase
if alpha not in string.lower():
return False
return True
#main
string = input("Enter any string: ")
#Function call
if(pangram(string) == True):
print("\n The given string is a pangram")
else:
print("\n The given string is not a pangram")
'''
Test cases:
1) Input: The Quick Brown Fox Jumps Over The Lazy Dog
Output: The given string is a pangram
2) Input: 2brown5! #(including special characters and digits)
Output: The given string is not a pangram
Time complexity: O(n)
Space Complexity : O(1)
'''