Наиболее часто встречающееся и самое длинное слово в тексте



Напишите программу, которая принимает текст и выводит два слова: то, которое встречается в тексте чаще всего, и самое длинное.

import collections

text = 'lorem ipsum dolor sit amet amet amet'
words = text.split()
counter = collections.Counter(words)
most_common, occurrences = counter.most_common()[0]

longest = max(words, key=len)

print(common, longest)


Добавить комментарий

;-) :| :x :twisted: :smile: :shock: :sad: :roll: :razz: :oops: :o :mrgreen: :lol: :idea: :grin: :evil: :cry: :cool: :arrow: :???: :?: :!: