December 30, 2021
Yesterday 가사가 저장되어 있는 텍스트 파일을 읽어 가사에 사용되고 있는 단어들의 목록을 알파벳 순서로 출력하고, 각 단어들이 몇 개씩 사용되고 있는지 단어별 개수를 출력하는 프로그램 작성
`f1=open('yesterday.txt', 'r')`
total=''
while True:
line = f1.read()
if not line:
break
strings = line.strip('\\n')
total += (strings+' ')
low_total = total.lower()
words_list=set(low_total.split())
words_list=sorted(words_list)
words=low_total.split()
result = {}
for i in words_list:
cnt= words.count(i)
result= {i : cnt}
print(result)
`f1.close()`