Skip to content · ⁨본문 바로가기⁩

Most common word

English

Most common word

Find the favourite word of a piece of text.

Work in three stages. Clean: remove the punctuation with .replace() and make everything lowercase with .lower(). Count: .split() the text into words and count them in a dictionary with counts.get(word, 0) + 1. Choose: walk through the words in their original order and switch to a word only when its count is strictly bigger, so that a tie goes to the earlier word.

한국어

가장 흔한 단어

텍스트의 가장 좋아하는 단어를 찾습니다.

세 단계로 수행합니다. 정제: .replace()으로 문장 부호를 제거하고 .lower()로 모든 것을 소문자로 만듭니다. 카운팅: .split()으로 텍스트를 단어로 나누어 counts.get(word, 0) + 1 사전을 통해 세きます. 선택: 원본 순서대로 단어를 순회하며 세수가 엄격하게 클 때만 단어를 교체하여, 동점인 경우 앞선 단어가 선택되게 합니다.

Log in or create account · ⁨로그인 또는 계정 만들기⁩

IGCSE, A-Level & AP