Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.22 KB | None | 0 0
  1. import re
  2. sent = 'a b c b c c A B C B C C'
  3. match = re.search('\w+', sent)
  4. while match:
  5. word = match.group()
  6. sent, count = re.subn(word, '', sent, flags=re.I)
  7. match = re.search('\w+', sent)
  8. print(word, count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement