length_report(text) that returns a dict mapping each distinct word length to how many words of that length appear in text (split on whitespace, strip punctuation .,!? from the ends of words, ignore empties). Use a dict comprehension over the set of lengths.length_report('hi bye, no go!'){2: 3, 3: 1}Words are hi, bye, no, go → lengths 2,3,2,2.
lengths = [len(w.strip('.,!?')) for w in text.split() if w.strip('.,!?')]
{n: lengths.count(n) for n in set(lengths)} finishes it.