question about for cycle

John Machin sjmachin at
Sat Sep 29 15:01:26 CEST 2007

On Sep 29, 8:04 pm, "fdu.xia... at" <fdu.xia... at>

> And I have another question. Which is the most efficient way to check if there
> are duplicate items in a list ? The items in the list may cannot be hashed, so
> set() may not work on the list.

The following classic by Tim Peters answers the question "How do I
remove duplicate items from a list".

It should help -- provided of course that you mean "duplicates" in the
sense that two Python objects a and b are duplicates iff a == b.
If you mean duplicates in a fuzzier sense e.g. "Mao Zedong" and "Mao
Tse-Tung", the problem gets harder ...


More information about the Python-list mailing list