I have a code snippet that I have used to count the duplicates in a list as
such:

from sets import Set

def countDups(duplicateList):
  uniqueSet = Set(item for item in duplicateList)
  return[(item, duplicateList.count(item)) for item in uniqueSet]


lst = ['word', 'word', 'new', 'new', 'new']
print countDups(lst)

The result is: [('new', 3), ('word', 2)], which is what is expected.  This
was using python version 2.7.  I want to do the same thing in Python 3.1,
but I'm not sure what has replaced Set in the newer version, can someone
give me an idea here?

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

Reply via email to