[Tutor] how to remove the coming duplication
delegbede at dudupay.com
delegbede at dudupay.com
Thu Nov 10 08:29:02 CET 2011
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 <lina.lastname at gmail.com>
Sender: tutor-bounces+delegbede=dudupay.com at python.org
Date: Thu, 10 Nov 2011 15:10:57
To: tutor<Tutor at python.org>
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 - Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list