Guest User

Untitled

a guest
Apr 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. from collections import defaultdict
  2.  
  3. list_words = str.split(' ')
  4. ddict = defaultdict(int)
  5. for k in list_words:
  6. ddict[k] += 1+= 1
  7.  
  8. from collections import Counter
  9. s = "1 Let's try to be Good. 2 Being good doesn't make sense. 3 Good is always good."
  10. s1 = s.split(' ')
  11. counts = Counter(s1)
  12. print(counts)
  13.  
  14. Counter({'': 6, '1': 1, "Let's": 1, 'try': 1, 'to': 1, 'be': 1, 'Good.': 1, '2': 1, 'Being': 1, 'good': 1, "doesn't": 1, 'make': 1, 'sense.': 1, '3': 1, 'Good': 1, 'is': 1, 'always': 1, 'good.': 1})
Add Comment
Please, Sign In to add comment