Kodewick
Start learning →
Mini challenge←→0 / 100

Word tally

#066Mini challengeDictsStrings6 min

You are writing a diary and want to see which words you use most. Write word_tally(sentence) to return a dict of each word to how often it appears. Ignore case (make words lowercase), strip .,!? off the ends of words, and keep the order words first appear. An empty sentence gives {}.

Examples
word_tally("The sun is up. The sky is blue!")→{'the': 2, 'sun': 1, 'is': 2, 'up': 1, 'sky': 1, 'blue': 1}
word_tally("Go, go, GO!")→{'go': 3}
main.py
def word_tally(sentence):
    tally = {}
    for word in sentence.split():
        # your code here: lowercase it, strip .,!?
        # then count it in tally
        pass
    return tally
Ctrl + Enter runs too
Result

Run tries the examples. When they look right, Submit.