word_frequencies(text) that returns a dict mapping each lowercase word in text to how many times it appears. Words are separated by whitespace, and punctuation such as ., ,, !, ? should be stripped from each word before counting.word_frequencies("The cat sat. The cat ran!"){'the': 2, 'cat': 2, 'sat': 1, 'ran': 1}Case is normalized to lowercase and trailing punctuation is stripped before counting.
Use text.lower().split() to get raw tokens, then word.strip(".,!?") on each.
Build the counts with a plain dict and .get(word, 0) + 1, or collections.Counter.