Returning histogram-like data for items in a list

jeethu_rao jeethurao at gmail.com
Thu Jul 21 21:21:53 EDT 2005


Adding to George's reply, if you want slightly more performance, you
can avoid the exception with something like

def hist(seq):
    h = {}
    for i in seq:
	h[i] = h.get(i,0)+1
    return h.items()

Jeethu Rao




More information about the Python-list mailing list