[Tutor] Testing if a number occurs more than once
Alfred Milgrom
fredm@smartypantsco.com
Tue Dec 3 02:46:07 2002
I've just been playing with List Comprehension and Functional Programming,
so here is a much simpler solution which returns the duplicates in your list:
duplicates = filter((lambda x:list.count(x)>1), list)
If there are no entries doubled in your list, duplicates will be an empty
list. Otherwise each duplicated entry will appear in duplicates (as many
times as it appears in the list).
Best regards,
Fred Milgrom