x = raw_input("Enter string: ") def frequencies(x): d = dict() for c in x: if c not in d: d[c] = 1 else: d[c] += 1 return d
filename = 'readlines.txt' with open(filename, 'r') as text_file: x = text_file.read() def frequencies(x): d = dict() for c in x: if c not in d: d[c] = 1 else: d[c] += 1 return d print frequencies(x)
Comment