0
how to get duplicates out of list
4 Respuestas
+ 3
Try this
my_list = [3, 5, 2, 1, 4, 4, 1]
my_list.sort()
for i in range(0,len(my_list)-1):
if my_list[i] == my_list[i+1]:
print (str(my_list[i]) + ' is a duplicate')
+ 1
You are welcome
0
thank you
0
you can transform your list into set - a collection that doesn't have duplicates, and then transform it back to a list
simply and one-line:
myList = list(set(myList))