I\'m trying to analyze the contents of a string. If it has a punctuation mixed in the word I want to replace them with spaces.
For example, If Johnny.Appleseed!is:a*good
How about using Counter from collections ?
import re from collections import Counter words = re.findall(r'\w+', string) print (Counter(words))