Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Popular Words by anieruth
def popular_words(text: str, words: list[str]) -> dict[str, int]:
text = text.lower().split()
return {word: text.count(word) for word in words}
assert popular_words(
"\nWhen I was One\nI had just begun\nWhen I was Two\nI was nearly new\n",
["i", "was", "three", "near"],
) == {"i": 4, "was": 3, "three": 0, "near": 0}
print("The mission is done! Click 'Check Solution' to earn rewards!")
Oct. 20, 2025
Comments: