Makistos
12/14/2016 - 2:01 PM

Given a word, check which lines of text in a file contain all the letters in that word. Takes two parameters: file name with the lines of te

Given a word, check which lines of text in a file contain all the letters in that word. Takes two parameters: file name with the lines of text and the letters to search. #python #hidden-word #list-comprehension

# Slurp file into list
with open(sys.argv[1]) as f:
    names = f.read().splitlines()

to_search = sys.argv[2].lower()

answer = [x for x in names if all(True if to_search.count(item) <= x.lower().count(item) else False for item in set(to_search))]

print answer