question about for cycle
sjmachin at lexicon.net
Sat Sep 29 15:01:26 CEST 2007
On Sep 29, 8:04 pm, "fdu.xia... at gmail.com" <fdu.xia... at gmail.com>
> 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