Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Least likely first (lower()) solution in Creative category for Pangram by Peter.White
'''
Check if a string is a pangram
'''
# Aiming for a fast solution, so check least likely letters first
# according to the interwebs, this is the list of letters, sorted
# from least likely to most likely:
# zqxjkvbpygfwmucldrhsnioate
LETTERS = 'zqxjkvbpygfwmucldrhsnioate'
def check_pangram(text):
'''
Input: text as a string
Output: True if text is a pangram, else False
'''
text_lower = text.lower()
for letter in LETTERS:
if letter not in text_lower:
return False
return True
if __name__ == '__main__':
# These "asserts" using only for self-checking and not necessary for auto-testing
assert check_pangram("The quick brown fox jumps over the lazy dog."), "brown fox"
assert not check_pangram("ABCDEF"), "ABC"
assert check_pangram("Bored? Craving a pub quiz fix? Why, just come to the Royal Oak!"), "Bored?"
March 29, 2015
Comments: