python
beginner
हल किया
2026-11-17 को समाप्त
Word frequency report
Write top_words(text, k) that returns the k most common words as a list of (word, count) tuples.
- Words are compared case-insensitively and returned in lowercase.
- Ignore punctuation:
"Hello, hello!"countshellotwice. - Sort by count (highest first); break ties alphabetically.
Acceptance criteria
- Handles an empty string (returns
[]). - The tests at the bottom print
All tests passed.
Hint: re.findall(r"[a-z']+", text.lower()) and collections.Counter.
अब तक 0 लोगों ने हल किया।
एडिटरCtrl + Enter
जब टेस्ट "All tests passed" दिखाते हैं, तो चैलेंज इस ब्राउज़र में हल के रूप में चिह्नित हो जाता है।
अपना समाधान समीक्षा के लिए भेजें