Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.19 KB | None | 0 0
  1. my_string = "To Be or not To Be"
  2. my_dict = {}
  3. for word in my_string.split():
  4. my_dict[word] = my_dict.get(word, 0)+1
  5. for word in my_dict:
  6. print("%s occurs %d times."%(word,my_dict[word]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement