我给存储在一个名为words_list
列表的文本文件中的单词的所有元音数量:寻找
if __name__ = "__main__":
words_file = open('words.txt')
words_list = []
for w in words_file:
w = w.strip().strip('\n')
words_list.append(w)
这就是字符串列表样子(这是一个好长好长的名单字)
我必须找到“所有的单词”与所有的元音;到目前为止,我有:
def all_vowel(words_list):
count = 0
for w in words_list:
if all_five_vowels(w): # this function just returns true
count = count + 1
if count == 0
print '<None found>'
else
print count
的问题,这是count
1次它看到一个元音每次增加,而我希望它加1 只有如果整个单词拥有所有的元音。
.strip后'()','.strip( '\ n')'是多余的。 – 2013-02-25 17:50:12