Skip to content · ⁨Pular para o conteúdo⁩

Most common word · ⁨Palavra mais comum⁩

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.

Português

Palavra mais comum

Encontre a palavra favorita de um texto.

Trabalhe em três etapas. Limpar: remova a pontuação com .replace() e torne tudo minúsculo com .lower(). Contar: .split() o texto em palavras e conte-as em um dicionário com counts.get(word, 0) + 1. Escolher: percorra as palavras na ordem original e mude para uma palavra apenas quando sua contagem for estritamente maior, para que um empate vá para a palavra anterior.

Log in or create account · ⁨Entrar ou criar conta⁩

IGCSE, A-Level & AP