Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.33 KB | None | 0 0
  1. sentence = input().split()
  2. d = dict()
  3. max_count = 0
  4. for word in sentence:
  5.     if word in d:
  6.         d[word] += 1
  7.     else:
  8.         d[word] = 1
  9. for word in d:
  10.     if d[word] > max_count:
  11.         max_count = d[word]
  12.         max_word = word
  13.     elif d[word] == max_count:
  14.         max_word = min(word, max_word)
  15. print(max_word)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement