Skip to content · ⁨Lompat ke konten⁩

Most common word · ⁨Kata paling umum⁩

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.

Bahasa Indonesia

Kata paling umum

Temukan kata favorit dari sebuah teks.

Bekerja dalam tiga tahap. Bersihkan: hapus tanda baca dengan .replace() dan buat semuanya huruf kecil dengan .lower(). Hitung: .split() teks menjadi kata-kata dan hitung dalam kamus dengan counts.get(word, 0) + 1. Pilih: berjalan melalui kata-kata sesuai urutan aslinya dan beralih ke kata hanya jika jumlahnya lebih besar secara ketat, sehingga jika seimbang, kata yang muncul lebih awal akan menang.

Log in or create account · ⁨Masuk atau buat akun⁩

IGCSE, A-Level & AP