Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- input_data = input()
- input_data = re.split(r'[\-.,\s;:?!]+', input_data)
- counter = {}
- for word in input_data:
- if word in counter.keys():
- counter[word] = counter[word] + 1
- else:
- counter[word] = 1
- output = []
- for word in counter:
- output.append([counter[word], word])
- output.sort()
- output.reverse()
- for word in output:
- print(word[0], '-', word[1])
Advertisement
Add Comment
Please, Sign In to add comment