Array delete

Jerry Hill malaclypse2 at gmail.com
Wed Feb 7 16:35:27 EST 2007


On 1/28/07, Scripter47 <nospam at riddergarn.dk> wrote:
> Can someone plz make a function for that takes a array, and then search
> in it for duplicates, if it finds 2 or more items thats the same string
> then delete all except 1.

 >>> myList = [1, 1, 2, 4, 8, 8, 8, 8, 8, 8, 10]
 >>> myList = list(set(myList))
 >>> print myList
 [8, 1, 2, 4, 10]

Maintaining sort order is left as an exercise for the reader.

-- 
Jerry



More information about the Python-list mailing list