<davidheise...@gmail.com> wrote
How about this?

List = [1, 2, 3, 3, 3, 4, 5, 5]
for Item in list(set(List)):
    print Item, List.count(Item)

Not bad and you don't need the convert back to list()
But it doesn't filter out those items which are unique which the OP asked for.

So I guess it becomes

for item in set(List):
   n = List.count(item)
   if n > 1:
       print item, n

which is still pretty clear.

--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to