def word_count (x: str) -> str:
characters = len(x)
word = len(x.split())
average = sum(len(x) for x in word)/len(word)
print('Characters: ' + str(char) + '\n' + 'Words: ' + str(word) + '\n' + 'Avg word length: ' + str(avg) + '\n')
This code works fine for normal strings, but for a string like:
'***The ?! quick brown cat: leaps over the sad boy.'
How do I edit the code so that figures like "***" and "?!" aren't accounted for in the code? The average word count of the sentence above should turn out to be 3.888889, but my code is giving me another number.