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
try this: it parses the word_list using re, then creates a dictionary of word:appearances
import re word_list = re.findall(r"[\w']+", string) print {word:word_list.count(word) for word in word_list}