+ 1

print out all words without an 'e' from .txt file of words

Lets say I have a file names words.txt and in this file, you words on each line eg txt file hello pizza pepper people planes plain I would like to print out all the words that do not contain letter 'e'... How? This is what I thought but it doesnt work correctly fin = open('words.txt') def no_e(fin): for line in fin: word = line.strip() for letter in word: if letter == 'e': return False else: print(word) no_e(fin)

26th Sep 2017, 3:55 AM
JUGHEAD
JUGHEAD - avatar
2 Answers
+ 2
def no_e(fin): for line in fin: word = line.strip() if 'e' not in word: print(word) no_e(fin)
26th Sep 2017, 4:20 AM
ChaoticDawg
ChaoticDawg - avatar