Hello, Here is my code for a letter frequency counter. It seems bloated to me and any suggestions of what would be a better way (keep in my mind I'm a beginner) would be greatly appreciated..
def valsort(x): res = [] for key, value in x.items(): res.append((value, key)) return res def mostfreq(strng): dic = {} for letter in strng: if letter not in dic: dic.setdefault(letter, 1) else: dic[letter] += 1 newd = dic.items() getvals = valsort(newd) getvals.sort() length = len(getvals) return getvals[length - 3 : length] thanks much!! -- http://mail.python.org/mailman/listinfo/python-list