# Uses a set to count words in Moby-Dick, # and measures/prints the code's runtime. import time def main(): # count the unique words in the file start = time.clock() words = set() with open("mobydick.txt") as file: for word in file.read().lower().split(): words.add(word) end = time.clock() # report results print("Unique words =", len(words)) print("Runtime:", round(end - start, 2), "sec") main()