Guest User

Untitled

a guest
Jun 23rd, 2014
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import re
  2.  
  3. input_data = input()
  4.  
  5. input_data = re.split(r'[\-.,\s;:?!]+', input_data)
  6.  
  7. counter = {}
  8.  
  9. for word in input_data:
  10.     if word in counter.keys():
  11.         counter[word] = counter[word] + 1
  12.     else:
  13.         counter[word] = 1
  14.  
  15. output = []
  16.  
  17. for word in counter:
  18.     output.append([counter[word], word])
  19.  
  20. output.sort()
  21. output.reverse()
  22.  
  23. for word in output:
  24.     print(word[0], '-', word[1])
Advertisement
Add Comment
Please, Sign In to add comment