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,
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
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_
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
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
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] -
[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
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
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? 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
10 matches
Mail list logo