Using Set() in Python Pangram Checking Last Updated : 14 Mar, 2023 Comments Improve Suggest changes Like Article Like Report Given a string check if it is Pangram or not. A pangram is a sentence containing every letter in the English Alphabet. Lowercase and Uppercase are considered the same. Examples: Input : str = 'The quick brown fox jumps over the lazy dog' Output : Yes // Contains all the characters from ‘a’ to ‘z’ Input : str='The quick brown fox jumps over the dog' Output : No // Doesn’t contains all the characters from ‘a’ // to ‘z’, as ‘l’, ‘z’, ‘y’ are missing This problem has existing solution please refer Pangram Checking link. We will solve this in Python using Set() data structure and List() comprehension. Approach is very simple, Convert complete sentence in lower case using lower() method of string data type in python.Now pass this sentence into Set(str) so that we could have list of all unique characters present in given string.Now separate out list of all alphabets (a-z), if length of list is 26 that means all characters are present and sentence is Pangram otherwise not. Implementation: Python3 # function to check pangram def pangram(input): # convert input string into lower case input = input.lower() # convert input string into Set() so that we will # list of all unique characters present in sentence input = set(input) # separate out all alphabets # ord(ch) returns ascii value of character alpha = [ ch for ch in input if ord(ch) in range(ord('a'), ord('z')+1)] if len(alpha) == 26: return 'true' else: return 'false' # Driver program if __name__ == "__main__": input = 'The quick brown fox jumps over the lazy dog' print (pangram(input)) Java import java.util.*; public class PangramChecker { public static void main(String[] args) { // Define the input string String input = "The quick brown fox jumps over the lazy dog"; // Call the pangram function and print the result System.out.println(pangram(input)); } public static String pangram(String input) { // Convert the input string to lowercase input = input.toLowerCase(); // Create a set to store unique characters in the input string Set<Character> inputSet = new HashSet<>(); // Loop through each character in the input string for (int i = 0; i < input.length(); i++) { char ch = input.charAt(i); // Check if the character is an alphabet if (ch >= 'a' && ch <= 'z') { // Add the character to the input set inputSet.add(ch); } } // Convert the input set to a list and sort it List<Character> alpha = new ArrayList<>(inputSet); Collections.sort(alpha); // Create a StringBuilder to concatenate the sorted characters into a string StringBuilder sb = new StringBuilder(); for (char ch : alpha) { sb.append(ch); } String uniqueChars = sb.toString(); // Check if the length of the resulting string is 26 (i.e., contains all alphabets) if (uniqueChars.length() == 26) { return "true"; } else { return "false"; } } } Outputtrue Time complexity: Lowercasing the input string takes O(n) time, where n is the length of the string.Converting the input string to a set takes O(n) time.The list comprehension that separates out all alphabets takes O(n) time. The len() function to count the number of alphabets takes O(1) time. The overall time complexity of the function is therefore O(n). Auxiliary space: Creating the set to store unique characters in the input string requires O(n) space, where n is the length of the string. Creating the list of alphabets requires O(k) space, where k is the number of alphabets in the string (which is at most 26). The overall auxiliary space complexity of the function is therefore O(n). Comment More infoAdvertise with us Next Article Using Set() in Python Pangram Checking S Shashank Mishra Follow Improve Article Tags : Strings Python DSA python-set Practice Tags : pythonpython-setStrings Similar Reads Python set to check if string is pangram Given a string, check if the given string is a pangram or not. Examples: Input : The quick brown fox jumps over the lazy dog Output : The string is a pangram Input : geeks for geeks Output : The string is not pangram A normal way would have been to use frequency table and check if all elements were 2 min read Python - Check if substring present in string The task is to check if a specific substring is present within a larger string. Python offers several methods to perform this check, from simple string methods to more advanced techniques. In this article, we'll explore these different methods to efficiently perform this check.Using in operatorThis 2 min read Check if String Contains Substring in Python This article will cover how to check if a Python string contains another string or a substring in Python. Given two strings, check whether a substring is in the given string. Input: Substring = "geeks" String="geeks for geeks"Output: yesInput: Substring = "geek" String="geeks for geeks"Output: yesEx 8 min read Check if given String is Pangram or not Given a string s, the task is to check if it is Pangram or not. A pangram is a sentence containing all letters of the English Alphabet.Examples: Input: s = "The quick brown fox jumps over the lazy dog" Output: trueExplanation: The input string contains all characters from âaâ to âzâ.Input: s = "The 6 min read Python | Pandas Series.isin() Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Pandas Series.isin() function check whether 2 min read Python Set | Check whether a given string is Heterogram or not Given a string S of lowercase characters. The task is to check whether a given string is a Heterogram or not using Python. A heterogram is a word, phrase, or sentence in which no letter of the alphabet occurs more than once. Input1: S = "the big dwarf only jumps"Output1: YesExplanation: Each alphabe 3 min read Check if a string is Pangrammatic Lipogram To understand what a pangrammatic lipogram is we will break this term down into 2 terms i.e. a pangram and a lipogram Pangram: A pangram or holoalphabetic sentence is a sentence using every letter of a given alphabet at least once. The best-known English pangram is "The quick brown fox jumps over th 14 min read Calculating Areas Of Different Shapes Using Python We are going to make a Python program for Calculating Areas Of some mathematical Shapes. Example: Input: shape name = "Rectangle" length = 10 breadth = 15 Output: Area: 150 Input: shape name = "Square" side = 10 Output: Area: 100 Approach: In this program, We will ask the user to input the shape's n 2 min read Check for True or False in Python Python has built-in data types True and False. These boolean values are used to represent truth and false in logical operations, conditional statements, and expressions. In this article, we will see how we can check the value of an expression in Python.Common Ways to Check for True or FalsePython pr 2 min read Python | Pandas TimedeltaIndex.contains Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric python packages. Pandas is one of those packages and makes importing and analyzing data much easier. Pandas TimedeltaIndex.contains() function checks if the passed label is present in the 2 min read Like