Francis Girard wrote: > Hi, > > I think your last solution is not good unless your "list" is sorted (in which > case the solution is trivial) since you certainly do have to see all the > elements in the list before deciding that a given element is not a duplicate. > You have to exhaust the iteratable before yielding anything.
Last solution? All of them have essentially the same logic to decide which items to reject. Further, what you say is true only if you are interpreting Steven's ambiguous(?) requirement as: remove ALL instances of a bunch of duplicates. Such a requirement would seem to be (a) just a tad unlikely and (b) contrary to the output of solutions already shown, which have brought no protest from Steven. So, just to remove ambiguity, WHICH one of the bunch should be retained? Short answer: "the first seen" is what the proverbial "man in the street" would expect -- "Have you voted already today?" -- it's a practical requirement and doesn't need any more complicated data structure than a set of folk who've already voted and no sleeve-rolling-up. -- http://mail.python.org/mailman/listinfo/python-list