Pangram checker

From Rosetta Code
Revision as of 19:12, 25 January 2010 by rosettacode>Paddy3118 (New task and Python solution.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Task
Pangram checker
You are encouraged to solve this task according to the task description, using any language you may know.

Write a function or method to check a sentence to see if it is a pangram or not and show its use.

A pangram is a sentence that contains all the letters of the alphabet at least once, for example: The quick brown fox jumps over the lazy dog.

Python

Using set arithmetic: <lang python>import string

def ispangram(sentence, alphabet=string.ascii_lowercase):

   alphaset = set(alphabet)
   return (set(sentence.lower()) & alphaset) == alphaset

print ( ispangram(input('Sentence: ')) )</lang>

Sample output:

Sentence: The quick brown fox jumps over the lazy dog
True