[python] 딕셔너리 연습

juri·2021년 6월 23일
0

Python

목록 보기
1/5
post-thumbnail

👉 딕셔너리를 이용한 제일 많이 등장한 단어 찾기

새로운 방법을 찾아서 메모 📝 !!

f = open('friends101.txt', 'r')

lst = []
for line in f :
    words = line.split()
    for word in words :
        lst.append(word)

print(max(set(lst), key=lst.count))

여기서 💥뽀인뜨💥는
max함수에 key값으로 count메서드를 적용한 것

profile
Make my day !

0개의 댓글