转自我的博客园:http://www.cnblogs.com/vickey-wu/p/6579653.html
l = [1,2,3,2,1] # l = ['你','我','他','她','你'] for i in l: print("the %s has found %s" % (i, l.count(i))) #find duplicate number # print("the %s has found %s" % (i, l.count(i))) #find duplicate string #the method above would repeat count duplicate data ,so we need to remove duplicate first print 'split line ----------------------------' s = set(l) for j in s: print("the %s has found %s" % (j, l.count(j))) #find duplicate number print("the %s has found %s" % (j, l.count(j))) #find duplicate number