[EMAIL PROTECTED] wrote: > Hi, > Suppose i have a list v which collects some numbers,how do i > remove the common elements from it ,without using the set() opeartor. > Thanks > > Several ways, but probably not as efficient as using a set. (And why don't you want to use a set, one wonders???)
>>> l = [1,2,3,1,2,1] Using a set: >>> set(l) set([1, 2, 3]) Building the list element by element: >>> for e in l: ... if e not in r: ... r.append(e) ... >>> print r [1, 2, 3] Using a dictionary: >>> d = dict(zip(l,l)) >>> d {1: 1, 2: 2, 3: 3} >>> d.keys() [1, 2, 3] >>> -- http://mail.python.org/mailman/listinfo/python-list