Re: how to remove duplicated elements in a list?

2005-12-20 Thread Tom Anderson
On Mon, 19 Dec 2005, Brian van den Broek wrote: > [EMAIL PROTECTED] said unto the world upon 2005-12-19 02:27: >> Steve Holden wrote: >> >>> Kevin Yuan wrote: >>> >>>> How to remove duplicated elements in a list? eg. >>>> [1,2,3,1,2,3,

Re: how to remove duplicated elements in a list?

2005-12-20 Thread Tim N. van der Leeuw
Another way to do this, that also maintains order, is: >>> l = [3, 1, 'a', '@', -4, 'z', 'r', 1, '@', -4] >>> s = set() >>> l2 = [] >>> for v in l: ... if not v in s: ... s.add(v) ... l2.append(v) ... >>> l2 [3, 1, 'a', '@', -4, 'z', 'r'] I have no idea whether or not

Re: how to remove duplicated elements in a list?

2005-12-19 Thread Brian van den Broek
Alex Martelli said unto the world upon 2005-12-19 10:48: > Brian van den Broek <[EMAIL PROTECTED]> wrote: >... > >orig_list = [3,1,2,3,1,2,3,1,2,1,2,1,3] >new_list = list(set(orig_list)) >new_list.sort(cmp= lambda x,y: cmp(orig_list.index(x), >> >>orig_list.index(y))) >> >new_

Re: how to remove duplicated elements in a list?

2005-12-19 Thread Alex Martelli
Brian van den Broek <[EMAIL PROTECTED]> wrote: ... > >>> orig_list = [3,1,2,3,1,2,3,1,2,1,2,1,3] > >>> new_list = list(set(orig_list)) > >>> new_list.sort(cmp= lambda x,y: cmp(orig_list.index(x), > orig_list.index(y))) > >>> new_list > [3, 1, 2] > >>> A better way to exploit exactly the same i

Re: how to remove duplicated elements in a list?

2005-12-19 Thread Bengt Richter
On 19 Dec 2005 00:27:48 -0800, [EMAIL PROTECTED] wrote: > >Steve Holden wrote: >> Kevin Yuan wrote: >> > How to remove duplicated elements in a list? eg. >> > [1,2,3,1,2,3,1,2,1,2,1,3] -> [1,2,3]? >> > Thanks!! >> > >> >> >>&g

Re: how to remove duplicated elements in a list?

2005-12-19 Thread Kevin Yuan
2005/12/19, Brian van den Broek <[EMAIL PROTECTED]>: [EMAIL PROTECTED] said unto the world upon 2005-12-19 02:27:> Steve Holden wrote:>>>Kevin Yuan wrote:>>>>>How to remove duplicated elements in a list? eg. >>>[1,2,3,1,2,3,1,2,1,2,1,3] -

Re: how to remove duplicated elements in a list?

2005-12-19 Thread Brian van den Broek
[EMAIL PROTECTED] said unto the world upon 2005-12-19 02:27: > Steve Holden wrote: > >>Kevin Yuan wrote: >> >>>How to remove duplicated elements in a list? eg. >>>[1,2,3,1,2,3,1,2,1,2,1,3] -> [1,2,3]? >>>Thanks!! >>> >> >> &g

Re: how to remove duplicated elements in a list?

2005-12-19 Thread bonono
Steve Holden wrote: > Kevin Yuan wrote: > > How to remove duplicated elements in a list? eg. > > [1,2,3,1,2,3,1,2,1,2,1,3] -> [1,2,3]? > > Thanks!! > > > > >>> list(set([1,2,3,1,2,3,1,2,1,2,1,3])) > [1, 2, 3] > Would this have the chanc

Re: how to remove duplicated elements in a list?

2005-12-19 Thread Steve Holden
Kevin Yuan wrote: > How to remove duplicated elements in a list? eg. > [1,2,3,1,2,3,1,2,1,2,1,3] -> [1,2,3]? > Thanks!! > >>> list(set([1,2,3,1,2,3,1,2,1,2,1,3])) [1, 2, 3] regards Steve -- Steve Holden +44 150 684 7255 +1 800

how to remove duplicated elements in a list?

2005-12-18 Thread Kevin Yuan
How to remove duplicated elements in a list? eg. [1,2,3,1,2,3,1,2,1,2,1,3] -> [1,2,3]?Thanks!! -- http://mail.python.org/mailman/listinfo/python-list