I took a challenge on CodeEval. Although the code seems to work for the examples taken from the site, I feel it is not really pretty and must be more complicated than it should be.
The sentence 'A quick brown fox jumps over the lazy dog' contains every single letter in the alphabet. Such sentences are called pangrams. You are to write a program, which takes a sentence, and returns all the letters it is missing (which prevent it from being a pangram). You should ignore the case of the letters in sentence, and your return should be all lower case letters, in alphabetical order. You should also ignore all non US-ASCII characters.In case the input sentence is already a pangram, print out the string NULL.
import sys filepath = sys.argv f = open(filepath) wholealphabet = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', 's','t','u','v','w','x','y','z') for line in f: sortedletters = list(set(line.lower())) i = 0 while i != len(sortedletters): if wholealphabet.count(sortedletters[i]) != 0: i = i + 1 else: sortedletters.pop(i) missingletters = "" for letter in wholealphabet: if sortedletters.count(letter) == 0: missingletters +=letter if len(missingletters) == 0: print("NULL") else: print(missingletters)