import sys
from collections import Counter
listOfLetters = (sys.argv[1].split(','))
listOfLetters = "".join(listOfLetters)
def lettercounting(x):
c = Counter(listOfLetters)
o = {x: c.get(x) for x in list(sorted(c.keys(), reverse= True,
key=lambda key: (c.get(key))
))}
return o
print(lettercounting(listOfLetters))
This is my code and I can't figure out how I get it in ASCII descending order.
Current Output:
python CountLetters.py Firefox,is,having,trouble,recovering,your,win
dows,and,tabs
{'i': 5, 'r': 5, 'o': 5, 'e': 4, 'n': 4, 's': 3, 'a': 3, 'v': 2, 'g': 2, 't': 2, 'u': 2, 'b': 2, 'w': 2, 'd': 2,
'F': 1, 'f': 1, 'x': 1, 'h': 1, 'l': 1, 'c': 1, 'y': 1}
Expected Output:
python CountLetters.py Firefox,is,having,trouble,recovering,your,win
dows,and,tabs
{y:1 x:1 w:2 v:2 u:2 t:2 s:3 r:5 o:5 n:4 l:1 i:5 h:1 g:2 f:1 e:4
d:2 c:1 b:2 a:3 F:1}