counters = {}

file_name = input("Enter the name of the file to analyze: ")
f=open(file_name, "rt", encoding="utf-8")
for line in f:
    for char in line:
        # If it is a letter...
        if char.isalpha():
            char=char.lower()
            if char in counters:
                counters[char] += 1
            else:
                counters[char]=1   
f.close()


for char in sorted(counters.keys()):
   print(char, '->',counters[char])

with open('natija.txt', "wt") as w:
    for char in sorted(counters.keys(), key=lambda x: counters[x], reverse=True): 
        cnt = counters[char]
        w.write(char+"->"+str(cnt)+"\n")

r_dic={}
for l in open("natija.txt","rt"):
    t=l.split("->")
    r_dic[t[0]]=int(t[1].strip())
print(r_dic)   

