Comment changer ["a", "a", "a", 2,3,3,2,2] en ['a', 2,3].
def remove_duplicates(x):
list_a = []
for index,i in enumerate(x):
list_a.append(i)
if list_a.count(i) > 1:
list_a.remove(i)
return list_a
print remove_duplicates(["a","a","a",2,3,3,2,2])
#['a',2,3]
Ou plutôt, il semble que ce qui suit était bon.
def remove_duplicates(x):
y=[]
for i in x:
if i not in y:
y.append(i)
return y
Recommended Posts