I am doing an exercise from Allen Downey's book (Think Python, page 84) that says "Write a function called has_no_e that returns True if the given word doesn’t have the letter “e” in it." The author says the pattern that those exercises have in common is:
def has_no_e(word):
for letter in word:
if letter == 'e':
return False
return True
So I believe that is the answer. But how do you make this function call the words.txt list of words? I tried to do it this way but something is definitely wrong because my code just does not do anything. I see a blank line when I run it. And what I want is to make that function draw words from the words.txt file and tell me if each of them is True or False depending on the presence or absense of 'e'.
def has_no_e(list):
fin = open(list)
word = fin.readline()
for letter in word:
if letter == 'e':
return False
return True
has_no_e("words.txt")
Thank you.