SHARE
TWEET

Untitled

a guest Apr 23rd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import re
  2. d = {}
  3. f = open("lorem.txt")
  4. s = f.read()
  5. s = re.sub(r'[^\w\s]','',s)
  6. a = s.lower().split()
  7. dictionary = {}
  8. for word in a:
  9.     if word in dictionary.keys():
  10.         dictionary[word] += 1
  11.     else:
  12.         dictionary[word] = 1
  13. print(dictionary)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top