On 10/26/2009 4:04 AM, Nils Wagner wrote: > how can I obtain the multiplicity of an entry in a list > a = ['abc','def','abc','ghij']
That's a Python question, not a NumPy question. So comp.lang.python would be a better forum. But here's a simplest solution:: a = ['abc','def','abc','ghij'] for item in set(a): print item, a.count(item) This is horribly inefficient of course. If you have a big list, if would be *much* better to use defaultdict: from collections import defaultdict myct = defaultdict(int) for item in a: myct[item] += 1 print myct.items() fwiw, Alan Isaac _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion