Shi Mu wrote: > I used the following method to remove duplicate items in a list and > got confused by the error. > > >>>>a > > [[1, 2], [1, 2], [2, 3]] > >>>>noDups=[ u for u in a if u not in locals()['_[1]'] ] > > Traceback (most recent call last): > File "<interactive input>", line 1, in ? > TypeError: iterable argument required
>>> a [[1, 2], [1, 2], [2, 3]] >>> c=[] >>> for x in a: ... if x not in c: c.append(x) ... >>> c [[1, 2], [2, 3]] or (Python 2.4) >>> a [[1, 2], [1, 2], [2, 3]] >>> set([frozenset(u) for u in a]) set([frozenset([1, 2]), frozenset([2, 3])]) hth Daniel -- http://mail.python.org/mailman/listinfo/python-list