import re
full_sent = '***The ?! quick brown cat: leaps over the sad boy.'
alpha_sent = re.findall(r'\w+',full_sent)
print(alpha_sent)
It will display:
['The', 'quick', 'brown', 'cat', 'leaps', 'over', 'the', 'sad', 'boy']
To get the average, you can:
average = sum(len(word) for word in alpha_sent)/len(alpha_sent)
What will give: 3.77
source
share