"Becky Mcquilling" <[email protected]> wrote

from sets import Set

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

Can be abbreviated to:

def countDups(duplicateList):
return [(item, duplicateList.count(item)) for item in set(duplicateList)]

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?

set()

It has become a native type in v3.

HTH,


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


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

Reply via email to