بتل کد Battle Codeدارد باز می‌شود…

جواب «Most Common Words» چالش 2 از جلسه‌ی 33

سؤال

یک خط را عوض کن تا به جای کل شمارنده، دو کلمه‌ی پرتکرار با most_common چاپ شود. خروجی باید [('the', 3), ('and', 2)] باشد.

راهنما

print(c.most_common(2)).

یک جواب درست

from collections import Counter

words = "the cat and the dog and the bird".split()
c = Counter(words)
print(c.most_common(2))

اول خودت امتحان کن؛ جواب‌های دیگر هم قبول است. برگرد و خودت حلش کن