Advertisement
Programmin-in-Python

Checking if a String is a Pangram?

Dec 28th, 2020
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.69 KB | None | 0 0
  1. from string import ascii_lowercase, ascii_uppercase
  2.  
  3.  
  4. def pangram(s):
  5.     L1 = list(s)
  6.     L2, str2 = [], ""
  7.     k = 0
  8.  
  9.     while k < len(L1):
  10.         for i in L1:
  11.             if i in ascii_lowercase:
  12.                 if i not in L2:
  13.                     L2.append(i)
  14.  
  15.                 for j in L1:
  16.                     if (i == j) or (i == j.lower()):
  17.                         del L1[L1.index(j)]
  18.  
  19.             elif i in ascii_uppercase:
  20.                 if i.lower() not in L2:
  21.                     L2.append(i.lower())
  22.  
  23.                 for j in L1:
  24.                     if (i == j) or (i == j.upper()):
  25.                         del L1[L1.index(j)]
  26.  
  27.         k += 1
  28.  
  29.     L2.sort()
  30.  
  31.     for i in L2:
  32.         str2 += i
  33.    
  34.     if str2 == ascii_lowercase:
  35.         return "pangram"
  36.     else:
  37.         return "not pangram"
  38.  
  39.  
  40. val = pangram("The Quick Brown Fox Jumps Over The Lazy Dog")
  41. print(val)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement