From bc4078c9fd7e22060abf8cd16f7298293b3c235a Mon Sep 17 00:00:00 2001 From: Legaroid <113330573+legaroid@users.noreply.github.com> Date: Sun, 22 Oct 2023 18:32:25 +0530 Subject: [PATCH] Added pangram added python code that takes a string and tells if it is a pangram --- P/pangram/pangram.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 P/pangram/pangram.py diff --git a/P/pangram/pangram.py b/P/pangram/pangram.py new file mode 100644 index 00000000..f5da4273 --- /dev/null +++ b/P/pangram/pangram.py @@ -0,0 +1,30 @@ +''' +The code is for checking whether a given input string is a "pangram", that is, +it contains all the letters from A to Z at least once. +Assume the regular English alphabet of 26 letters. +Any extra letters, numbers, punctuation etc are ignored. + +Example: +Enter a string: the quick brown fox jumps over the lazy dog +The number is pangram! +''' + +def pangram(s): + l = len(s) + letters = set() + for char in s: + if char.isalpha() == True: + letters.add(char.lower()) + if len(letters) == 26: + return True + return False + +str = input("Enter a string:") + +result = pangram(str) + +if(result == True): + print("The number is pangram!") +else: + print("Not a pangram!") +