본문 바로가기
프로그램

[파이썬] 문제 : 딕셔너리 영어 단어 카운트

by 오디세이99 2023. 5. 4.
728x90
반응형

def count_words(ss):
    dic = {}
    for w in ss.split():
        if w in dic.keys():
            dic[w] += 1
        else:
            dic[w] = 1
    print(dic)
    
ss =  'I have a dream that one day this nation will rise up and out the true meaning of its creed'
count_words(ss)

728x90
반응형

댓글