Tuesday, 21 July 2015

Check Panagram

 Pangrams are sentences constructed by using every letter of the alphabet at least once.
Example : "The quick brown fox jumps over the lazy dog"
 Write a program to check given sentence to paragraph is pangrams or not.


  1. create a list of all char a...z  in small letters say list is ls.
  2. convert given string to small letters.
  3. Now chose char from given string one by one if that is found in ls then remove it from ls.
  4. Repeat step 3 until ls is empty of given string ends.
  5. if  ls is empty after step 4 then it is pangrams else not pangrams.

Python Source code to check pangrams sentance

  1. sentc=raw_input('Input string to check pangrams :') #input given string
  2. sentc=sentc.lower() #convert to lower case
  4. charc='abcdefghijklmnopqrstuvwxyz'
  5. ls=[]
  6. for ch in charc:
  7.     ls.append(ch)
  8. #ls contain all charcter a..z
  9. flag=False
  10. for ch in sentc:
  11.     if ch in ls:
  12.         ls.remove(ch)
  13.     if len(ls)==0:
  14.         flag=True
  15.         break;
  16. if flag:
  17.     print 'pangram'
  18. else:
  19.     print 'not pangram'

1 comment:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Data Science with Python , kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Sangita Mohanty
    E-mail: sangita@maxmunus.com
    Skype id: training_maxmunus
    Ph:(0) 9738075708 / 080 - 41103383



Blogger Widgets