Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- dictionary_2 = {}
- max = 0
- q = 0
- dictionary = {}
- file = open('Lorem.txt')
- s = file.read()
- s = re.sub(r'[^\w\s]','',s)
- a_list = s.lower().split()
- for word in a_list:
- q += 1
- if word in dictionary.keys():
- dictionary[word] += 1
- else:
- dictionary[word] = 1
- for word in dictionary:
- print(f'{word},{dictionary[word]},{round((dictionary[word] / q), 3)}%')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement