연습문제 답 #
1 #
with open(filename, 'r') as infile:
words = infile.read().split()
max_len = len(max(words, key=len))
return [word for word in words if len(word) == max_len]
print(longest_word('test.txt'))
2 #
from collections import Counter
with open(fname) as f:
return Counter(f.read().split())
print("Number of words in the file :",word_count("test.txt")