The simplest solution is the following:
with open("words.txt") as words: sum(1 for word in words if "e" not in word)
As you can see, sum works with any iterator - here I use a generator expression.
Instead of doing word.find('e') == -1 , we can just make "e" not in word , which is better to read and work, because the lines themselves are repeated and support __contains__ .
I also use the with statement to open files - it is preferable to manually open and close them, since it handles these things for you and correctly processes exceptions.
I would like to point out, however, your example works for me. I assume that your file is a space or a comma, but a loop through the file returns strings.
My test file:
bob bill james test something no
This, for example, will not work:
bob bill james test something no
How do we get one line containing all this. In this case, we can use str.split() to split the lines into words.
eg:
with open("words.txt") as lines: sum(1 for line in lines for word in line.split() if "e" not in word)
source share