dictionary = open('dictionary.txt','r')
def main():
print("part 4")
part4()
def part4():
naclcount = 0
for words in dictionary:
if 'nacl' in words:
naclcount = naclcount + 1
return naclcount
main()
基本的には正しい答え25が付属していますが、パート4の前に別の関数を入れた場合を除いて、0として出力されます.
def part1():
vowels = 'aeiouy'
vowelcount = 0
for words in dictionary:
words = words.lower()
vowelcount = 0
if len(words) == 8:
if 's' not in words:
for letters in words:
if letters in vowels:
vowelcount += 1
if vowelcount == 1:
print(words)
return words