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