# Count the number of words in a text file and # make a set of all the words in the file word_set = set() silly_file = open("silly.txt", "r") for line in silly_file: #print line, word_list = line.split() print word_list word_set = word_set | set(word_list) silly_file.close() print len(word_set), word_set