some small fixes

This commit is contained in:
Mari Wahl 2014-10-10 22:27:27 -04:00
parent ab70b811db
commit a50737bc6b
63 changed files with 8 additions and 19 deletions

View file

@ -0,0 +1,27 @@
#!/bin/python
import string
import sys
import operator
def find_frequency(msg):
dict_freq = dict([(c, 0) for c in string.lowercase])
total_letters = 0.0
for c in msg.lower():
if 'a'<= c <= 'z':
dict_freq[c] += 1
total_letters += 1
list_freq = sorted(dict_freq.items(), key=operator.itemgetter(1))
return list_freq
def main(filename):
with open(filename, 'r') as f:
cipher = f.readlines()
cipher = cipher[0].strip()
print(find_frequency(cipher))
if __name__ == "__main__":
main(str(sys.argv[1]))