Beginner's question: This program I made does what I am asked to make, except it does not sort the last letter count in descending order. How do I change the program to do that, please?
word = input("Paste the text you want anlysed: ")
import re
from collections import Counter
from string import ascii_letters
print("Word count: {}".format(len(word.split())))
print("Sentences ending with a ".": {}".format(len(re.findall(r'\.', word))))
print("Sentences ending with a "?": {}".format(len(re.findall(r'\?', word))))
print("Sentences ending with a "!": {}".format(len(re.findall(r'\!', word))))
parts = [len(l.split()) for l in re.split(r'[?!.]', word) if l.strip()]
print("Average word count per sentence: {}".format(sum(parts)/len(parts)))
def count_letters(s) :
filtered = [c for c in s.lower() if c in ascii_letters
return Counter(filtered)
count_letters(word)