Wie man ["a", "a", "a", 2,3,3,2,2] in ['a', 2,3] ändert.
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]
Oder besser gesagt, es scheint, dass das Folgende gut war.
def remove_duplicates(x):
y=[]
for i in x:
if i not in y:
y.append(i)
return y
Recommended Posts