Try this

>>> a=['2', '5', '7', '5', '5']

>>> d=list(set(a))

>>> d
['2','5','7']

Is there any reason why your numbers are in quotes???

Hope this helps. 
Sent from my BlackBerry wireless device from MTN

-----Original Message-----
From: lina <[email protected]>
Sender: [email protected]
Date: Thu, 10 Nov 2011 15:10:57 
To: tutor<[email protected]>
Subject: [Tutor] how to remove the coming duplication

Hi,

How to remove the coming duplication,

Here I wrote one (not working):


>>> a=['2', '5', '7', '5', '5']
>>> for i in range(len(a)-1):
        if a[i+1]==a[i]:
                a.remove(a[i+1])
        if i not in range(len(a)):
                break

        
>>> a
['2', '7', '5', '5']

I wish to get a is [2,5,7,5]

just remove the coming duplication, not unique the list.

Thanks for any advice,

Best regards,
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to