how to remove duplicated elements in a list?

Steve Holden steve at holdenweb.com
Mon Dec 19 03:21:16 EST 2005


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 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list