[Tutor] how to remove the coming duplication

lina lina.lastname at gmail.com
Thu Nov 10 08:10:57 CET 2011


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,


More information about the Tutor mailing list