Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. with open("source.txt") as f:
  2.     data = f.read()
  3.     words = data.split()
  4.     word_dict = dict()
  5.     for word in words:
  6.         if word in word_dict:
  7.             word_dict[word] += 1
  8.         else:
  9.             word_dict[word] = 1
  10.     max = 0
  11.     for key, value in word_dict.items():
  12.         if value > max:
  13.             max = value
  14.     moda = []
  15.     for key, value in word_dict.items():
  16.         if value == max:
  17.             moda.append(key)
  18.     print(max)
  19.     for el in moda:
  20.         print(el)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement