Write a Python function to check whether a string is pangram or not. Note : Pangrams are words or sentences containing every letter of the alphabet at least once. For example : "The quick brown fox jumps over the lazy dog

Example 1: how to find palingrams python

"""
Program:
 Python program to find anagrams in a list of strings
"""
from collections import Counter

def get_anagrams(input_string_list, test_string): 
   
   print("*******************")
   print("input_string_list = ", input_string_list)
   print("*******************\n")

   # Find the list of anagrams in the strings    
   out_string_list = list(filter(lambda x: (Counter(test_string) == Counter(x)), input_string_list)) 

   # Print the list of anagrams in the strings 
   print("*******************")
   print("out_string_list = ", out_string_list)
   print("*******************\n")

def Driver(): 
   input_string_list = ['Python', 'Program', 'Machine', 'yPtnoh', 'Learning']
   test_string = "ntoyPh"
   get_anagrams(input_string_list, test_string)

if __name__=="__main__": 
   Driver()          # call Driver() function

Example 2: Write a Python function to check whether a string is pangram or not. Note : Pangrams are words or sentences containing every letter of the alphabet at least once. For example : "The quick brown fox jumps over the lazy dog

import string


def is_pangram(s, alphabet=string.ascii_lowercase):
    return set(alphabet) == set(s.replace(" ", "").lower())


text = "The quick brown fox jumps over the lazy dog"
assert is_pangram(text) is True

text = "Some text for testing"
assert is_pangram(text) is False

Tags:

Misc Example