Apr-29-2017, 05:22 PM
>>> text = """ ... spam eggs ... fish ... carrot dog worm ... mouse keyboard history lesson""".split() >>> >>> # with open(filename) as text: ... >>> word_count = 0 >>> for line in text: ... word_count += len(line.split()) ... >>> word_count 10