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