what I am trying to do:
By filtering the lowers list, create and print a list of the words which satisfy all of the following criteria:
the word is at least 6 characters long;
the word contains the letter 'e' at least 3 times;
the first occurrence of the letter 'e' is in the second half of the word.
I have this so far:
was used earlier:
words = [ line.strip() for line in file(DATA+'english_wordlist.txt') ]
(lowers was defined earlier in my work as a partial set of words)
[word for word in lowers if len(word)>=6 and word.count('e')>=3 and 'e' is after word(len(word)/2::)]
I know that 'e' is after word(len(word)/2::) is wrong but this just my rough logic. How exactly would i accomplish this?
Answer
and word.index('e') >= len(word)/2
No comments:
Post a Comment