Change language

Python set to test if a string is a panagram

|

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 

The usual way would be to use a frequency table and check if all elements were present or not. But by using import ascii_lowercase as asc_lower we import all the lower characters in the set and all the string characters in the other set. In the function, two sets of — one for all lowercase letters and one for letters in the line. The two sets are subtracted, and if it is an empty set, the string is a pangram.

Below is the Python implementation of the above approach:

# import from string all ascii_lowercase and asc_lower

from string import ascii_lowercase as asc_lower

 
# function to check the presence or absence of all elements

def check (s):

return set (asc_lower) - set (s.lower ()) = = set ([])

 
# driver code

strng = "The quick brown fox jumps over the lazy dog"

if (check (strng) = = True  ):

print ( "The string is a pangram" )

else :

print ( "The string isn’ta pangram" )

Output:

 The string is a pangram 

Shop

Learn programming in R: courses

$

Best Python online courses for 2022

$

Best laptop for Fortnite

$

Best laptop for Excel

$

Best laptop for Solidworks

$

Best laptop for Roblox

$

Best computer for crypto mining

$

Best laptop for Sims 4

$

Latest questions

NUMPYNUMPY

psycopg2: insert multiple rows with one query

12 answers

NUMPYNUMPY

How to convert Nonetype to int or string?

12 answers

NUMPYNUMPY

How to specify multiple return types using type-hints

12 answers

NUMPYNUMPY

Javascript Error: IPython is not defined in JupyterLab

12 answers

News


Wiki

Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | cv2.circle () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method