Skip to content

Instantly share code, notes, and snippets.

@mkowoods
Created November 18, 2014 02:12
Show Gist options
  • Save mkowoods/e24e67782c39b0ccf394 to your computer and use it in GitHub Desktop.
Save mkowoods/e24e67782c39b0ccf394 to your computer and use it in GitHub Desktop.
Quick Letter Count Script
def letter_frequency(text):
wdct = {}
for n in text:
m = n.lower()
if m.isalpha():
wdct[m] = wdct.get(m, 0) + 1
return sorted([(k,v) for k,v in wdct.iteritems()], key = lambda x : (-x[1], x[0]))
result = letter_frequency('IWT LDGAS XH HIXAA P LTXGS EAPRT, STHEXIT BN TUUDGIH ID BPZT RATPG PCS ETGUTRI HTCHT DU XI.')
print result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment